Question How to make a toggle switch in batch file ?

mcqc

Distinguished
Mar 9, 2010
45
0
18,540
How to toggle between this:

wmic process where name="ScpService.exe" CALL setpriority "high priority"

and this:

wmic process where name="ScpService.exe" CALL setpriority "normal"

When set to high, toggle to normal and when set to normal, toggle to high. Without creating 2 differents batch files.
 
That’s not gonna be possible in a batch file you need auto IT or some other scripting language to do that
 
  • Like
Reactions: mcqc
That’s not gonna be possible in a batch file you need auto IT or some other scripting language to do that
I got the answer I wanted on linustechtips forum from user badreg. Thank for your help anyway.


set processName=ScpService.exe
set "WMIC_CMD=wmic process where name^='%processName%' get /format:list ^| findstr Priority"

for /f "tokens=1* delims==" %%A in ('%WMIC_CMD%') do set priority=%%B

if %priority% == 8 (
wmic process where name^="%processName%" CALL setpriority "high priority"
) else (
wmic process where name^="%processName%" CALL setpriority "normal"
)