run bat file in background

后端 未结 3 1588
醉话见心
醉话见心 2020-12-17 03:27

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 f

相关标签:
3条回答
  • 2020-12-17 04:04

    You can try to run the batch file as a windows service. You will perhaps need to have admin previleges on your host to do this, but if you want to go for it, its easy to add/configure using sc command.

    0 讨论(0)
  • 2020-12-17 04:05

    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

    0 讨论(0)
  • 2020-12-17 04:11

    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");
    
    0 讨论(0)
提交回复
热议问题