Running a server in background using cmd shell for Windows

Advertisements

I am trying to run a file called CoreServer.exe in background using cmd shell as mentioned here. When I specify the path of the server, it tells me,

'.' is not recognized as an internal or external command,
operable program or batch file.

On the other hand if I remove shell: cmd it works fine. But in this case it runs using Poweshell and I don’t want that because running in Powershell is not what I want.

Here is my workflow file. I also have this in a public repo on GitHub here.

name: Test unit tests CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

  
jobs:
  build:

    runs-on: windows-2022

    steps:
    - uses: actions/checkout@v3

    - name: setup Msbuild
      uses: microsoft/setup-msbuild@v1.3.1
      

#try nc -v -N 127.0.0.1 3334
 #curl http://localhost:3333 -I
 #vstest.console.exe ./Pico/Medman/FluidTransferTests/bin/Release/net481/FluidTransferTests.dll
#Start CoreServer.exe in background
    
    - name: Start CoreServer.exe in the background
      shell: cmd
      run: ./Debug/CoreServer.exe -c -s &

    - name: Wait 7 seconds
      run: sleep 7

    - name: See status
      run: netstat -ntp

To add more information, when I run this CoreServer.exe in a command prompt on my local it runs fine and shows the following,

>Solution :

The windows shell doesn’t handle linux style path separators. ./debug must be .\debug, that will remove the error.

    - name: Start CoreServer.exe in the background
      shell: cmd
      run: .\Debug\CoreServer.exe -c -s &

Leave a ReplyCancel reply