Run batch file in background
You could make a shortcut to your batch file and place the shortcut in your Startup Programs directory:
C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Since you have to roll this out to several computers remotely, you should be able to copy the batch file to the startup programs directory over the network assuming the remote machines have WinRM enabled and your account has adequate permissions.
If you want this batch file to run in the background at start up, you could reference your batch file from a VBScript (instead of using the batch file's short cut) and set the VBscript to run in invisible mode:
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\path\to\your\batchfile.bat" & Chr(34), 0
Set WshShell = Nothing
Just give this vbscript file the .vbs extension.
Related videos on Youtube
WRJ
Updated on June 04, 2022Comments
-
WRJ almost 2 years
I've got a batch file that I want to run in the background whenever the system (Windows 2007) is turned on. The batch file monitors the task list for a given program, and when it sees that it's shut down, prompts the user to de-licence it.
I'm currently trying to do this without converting the batch file into either an executable or Windows service file.
I've found more online references than I can count which tell me that I should use "start /b file.bat" to run the batch file in the background, but this doesn't work for me, it just starts up the batch file in the same cmd line window that I'm using.
Can anyone suggest either what's going wrong, or even better; a nice simple way for me to get the batch file to run ion start up (I cannot use a GUI as I have to roll this out to several computers remotely)
Thanks
-
phuclv about 6 yearsthe largest Windows number ever released is 98, 2000 and 2003. There's no Windows 2007
-
phuclv about 6 yearsPossible duplicate of Execute Batch File without Command line visible
-
-
WRJ about 6 yearsHi Adam, thanks but I've tried this; the problem is that it will run the batch file in the foreground.
-
Adam about 6 yearsYou could run your batch file from a VBscript in invisible mode and place the vbscript in the start up programs directory. I've updated my answer to include this method.
-
Adam about 6 years@WRJ, if this helped or solved your issue, would you mind voting up the answer? Thanks!