.Bat Change priority process several times

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zebuguinho
Posts: 4
Joined: 16 Feb 2020 07:53

.Bat Change priority process several times

#1 Post by zebuguinho » 16 Feb 2020 07:58

I need a .bat file that changes the process priority several times, contains several processes with the same name, so I need the command to put the PID, I would like the process to be decreasing and increasing the priority alone, for 2min.
Can someone do this for me?

I need the process to change from high to low, after low to below normal, keep changing for 2min, the sequence does not matter.

What do I need to inform so that you can write a .bat like this for me? Thanks

zebuguinho
Posts: 4
Joined: 16 Feb 2020 07:53

Re: .Bat Change priority process several times

#2 Post by zebuguinho » 16 Feb 2020 20:32

upppp, help plz

aGerman
Expert
Posts: 3869
Joined: 22 Jan 2010 18:01
Location: Germany

Re: .Bat Change priority process several times

#3 Post by aGerman » 17 Feb 2020 03:42

See https://superuser.com/questions/620724/ ... mmand-line
The class has also a ProcessID member that you can use in the WHERE clause:

Code: Select all

wmic process where processid=12345 CALL setpriority 32768
Steffen

zebuguinho
Posts: 4
Joined: 16 Feb 2020 07:53

Re: .Bat Change priority process several times

#4 Post by zebuguinho » 17 Feb 2020 07:04

aGerman wrote:
17 Feb 2020 03:42
See https://superuser.com/questions/620724/ ... mmand-line
The class has also a ProcessID member that you can use in the WHERE clause:

Code: Select all

wmic process where processid=12345 CALL setpriority 32768
Steffen
Can you write the code for me? I need the process to change the priority several times during 2 min, going from low to high, I don't know how to do that, if you can write the code for me, I'll be very grateful, thanks

ShadowThief
Expert
Posts: 950
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: .Bat Change priority process several times

#5 Post by ShadowThief » 17 Feb 2020 07:09

That is the code

aGerman
Expert
Posts: 3869
Joined: 22 Jan 2010 18:01
Location: Germany

Re: .Bat Change priority process several times

#6 Post by aGerman » 17 Feb 2020 10:40

Please see the linked thread on SO. There are several priority levels. No idea what levels you're referring to. Include it in your batch file and come back with your code and a description of what still didn't work and/or the error message if you're facing any problems.

Steffen

zebuguinho
Posts: 4
Joined: 16 Feb 2020 07:53

Re: .Bat Change priority process several times

#7 Post by zebuguinho » 17 Feb 2020 13:05

wmic process where processid=12345 CALL setpriority 32768


I need .bat to make the process change its priority several times, going from normal to low, low to high, high to below normal, etc ... the sequence doesn't matter, I wanted the process to continue changing the priority for at least 2 minutes. Can anyone do this for me?

penpen
Expert
Posts: 1808
Joined: 23 Jun 2013 06:15
Location: Germany

Re: .Bat Change priority process several times

#8 Post by penpen » 20 Feb 2020 06:07

This might help you (just because you are here for the first time and i felt like it, but usually you have to try more than that):

Code: Select all

@echo off
setlocal enableExtensions enableDelayedExpansion
:: use the existing of a file as a signal
set "signal=signal.tmp.txt"
>"%signal%" rem:
:: delete file after 2 minutes == 120 seconds
start "" /b "%ComSpec%" /c"@(>nul timeout /t 3 /nobreak & del "%signal%")"

:loop
for %%a in ("high priority" "idle" "below normal" "normal") do for %%b in ("12345") do (
	if exist "%signal%" echo(wmic process where processid=%%~b CALL setpriority "%%~a"
)
if exist "%signal%" goto :loop

echo(Bye.
pause
goto :eof
penpen

Post Reply