• Now's your chance win big! Join our community and get entered to win a RTX 2060 GPU, plus more! Join here.

    Pi Cast Episode 3 streams live on Tuesday, August 4th at 2:30 pm ET (7:30 PM BST). Watch live right here!

    Catch Scharon on the Tom's Hardware Show live on Thursday, August 6th at 2:00 pm ET (7:00 PM BST). Click here!

Question How to make a toggle switch in batch file ?

mcqc

Distinguished
Mar 9, 2010
40
0
18,540
1
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.
 

mcqc

Distinguished
Mar 9, 2010
40
0
18,540
1
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"
)
 

ASK THE COMMUNITY

TRENDING THREADS