Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set process priority when starting an executable from a batch file in Windows without launching terminal

I have a .bat file [1] starting from a .vbs script [2] which only launches without launching a terminal if I don't include 'Start /low' in the .bat file.

The 'Start /low' part of the .bat file launches the command with the right (low) priority set, but it launches in a terminal, which I don't want.

I'm only able to launch the desired command in the background without a terminal if I don't set the priority in the .bat file. In which case the final .exe that launches slows my computer down, which is why I want to set its priority to 'low'.

I tried this [3], but it gives me an error when I run it [4].

Would someone kindly tell me how to make the executable start with low priority without launching a terminal window?

[1]

Start /low C:/dataserv-client/dataserv-client.exe --store_path=C:\Users\Chris\StorjData --max_size=800.0GB farm

[2]

Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Users\Chris\Scripts\start_dataserv-client.bat" & Chr(34), 0
Set WinScriptHost = Nothing

[3]

Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "Start /low C:/dataserv-client/dataserv-client.exe --store_path=C:\Users\Chris\StorjData --max_size=800.0GB farm" & Chr(34), 0
Set WinScriptHost = Nothing

4

enter image description here

like image 288
cdvonstinkpot Avatar asked Jan 22 '26 15:01

cdvonstinkpot


1 Answers

The code in [3] didn't work because 1) the closing quote added with chr(34) was in the wrong place - only the executable should be quoted this way, not the entire command line and 2) start isn't a standalone utility which can be executed directly by .Run, it's a command of the command processor cmd (easily checked by running where start in the command prompt console).

CreateObject("WScript.Shell").Run "cmd /c Start /low " & chr(34) & chr(34) & " " & _
     chr(34) & "C:\dataserv-client\dataserv-client.exe" & chr(34) & _
     " --store_path=C:\Users\Chris\StorjData --max_size=800.0GB farm", 0

which executes cmd /c start /low "" "C:\dataserv-client\dataserv-client.exe" ......... - the first "" is for the title parameter of start so that cmd won't confuse it with the quoted exe path.

like image 125
wOxxOm Avatar answered Jan 25 '26 14:01

wOxxOm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!