Main Point
It makes better sense to just use PSExec
to keep this simple for your particular need. The syntax is rather intuitive and typically just works, but the sample syntax I provided below should be all you need to use to make it work once connected to the VPN.
I'm not sure if you run this from the VPN-connected PC if the username will need to be <domain>\<username>
but keep this in mind when testing if you have trouble.
Sample Syntax
Important Note: Run from VPN-connected PC, point the BAT file path as it is from the Game Server's perspective
psexec -u user - p password \\remotepc "c:\mybatchfile.bat"
Further Ideas
Different Example: If the application runs in memory whether or not it's a service then the below will look to confirm that it's running
in memory. If it's not you could then tell it to run your process. I'm
not sure if it gets hung up and when that occurs you cannot find it
running with TASKLIST, but that may be something to check. You could
then schedule something like the below to run twice a day, etc. to
automate the process.
@ECHO OFF
:::: The remote machine the TASKLIST command is run against must accept incoming WMI traffic from the machine sending the request
:::: Enabling the firewall rule "Windows Management Instrumentation (WMI)" should do the trick
TASKLIST /S ServerName | FINDSTR /I applicationname.exe
IF ERRORLEVEL 1 (GOTO :StartSomething) ELSE (GOTO :EOF)
:StartSomethink
pushd %~dp0
cd /d %CD%
start /b "Dayz Epoch Server" /min "DayZ_Epoch_instance_11_Chernarus.bat"
timeout 15
cd "C:\Users\LostandCrazy\Desktop\DayZ Server\instance_11_Chernarus\BattlEye\Bec"
start "UEP BattlEye Extended Control" /min "BEC.exe" -f "Config.cfg"
taskkill /f /im cmd.exe
GOTO :EOF
Original Thoughts, etc.
Since you say the (batch) BAT file is on the server, and this server is what you connect to when you connect to the VPN then. . .
- when you connect to the VPN, remotely connect to the
server by signing onto it via RDP, and then launch the BAT file from
there
Note: If the BAT file is on the server in the first place, I have no idea why it's even be on your VPN-connected PC so that part is
confusing to me.
- The batch file will need to be run from the server so you need it to
run on the server itself. You can setup a scheduled task and
automate this too, or connect to the server via RDP to kick off
manually, etc.
- You're not going to be able to launch an EXE file from your "main"
PC, etc. that's on
\\servername\c$\program files\~
and expect that
to run in memory on the server.
An Update
With RDP you are only dragging the screen, mouse clicks, and keyboard
strokes across the network (i.e. VPN Internet tunnel in your case).
This means that RDP is typically a rather efficient protocol in terms
of network traffic.
Launching it remotely may be possible from the VPN-connected device
assuming it's connected to the domain of the VPN you connect to and
the server you want to launch it from is able to authenticate any
remote commands you send to the server to launch it.
If the VPN-connected device is not joined to the domain of the VPN
you connect to and the server is not able to authenticate, then you
may be able to launch some remote command with RUNAS
, etc.
You could just RDP into the server and wait for it to load and then
launch it that way, or else schedule a process—with task scheduler—on
the server with the batch file, and automate so it doesn't need to be
done manually.
There are batch script solutions you can put into place to "Do
Something" when "Something" occurs. You can have it send you an
email, etc. if "Something" occurs or is triggered.
Additionally. . .
- PowerShell can execute processes, etc. remotely but you'd have to
ensure prerequisites are in place and test to confirm it works as
expected.
- You can create a scheduled task on the server pointing to the BAT file and then potentially launch it remotely (so it would have NO SCHEDULE for automation so you could run ad hoc as-needed). Again, you'd have to test and confirm all this works as expected