Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run bat file in background

Tags:

batch-file

I want to run a bat file in background. I searched in google and I found some examples using hstart and cmdow. But Isn't anyway to do this with windows commands? I really feal good when I don't add extra programs to my project ! thanx in advance

like image 784
AliBZ Avatar asked Nov 10 '09 06:11

AliBZ


People also ask

How do I run a batch file in minimized mode?

Run batch file minimized from Windows Task Scheduler But if you want to run it minimized, then you have to make adjustments in the Actions tab. “^& exit” at the end is necessary to close the CMD window after the batch file is executed.

How do I run a command in the background?

If you want to run additional commands while a previous command runs, you can run a command in the background. If you know you want to run a command in the background, type an ampersand (&) after the command as shown in the following example. The number that follows is the process id.


2 Answers

I'm using window scheduler. I found a way :

Save this one line of text as file invisible.vbs:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

To run any program or batch file invisibly, use it like this:

wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"

thanx

like image 70
AliBZ Avatar answered Oct 13 '22 09:10

AliBZ


It really depends on the programming language and platform you are using.

In Windows, using the C# language on the .NET platform, it is:

System.Diagnostics.Process.Start(@"C:\myfile.bat");
like image 36
Robert Harvey Avatar answered Oct 13 '22 11:10

Robert Harvey