[Help] Batch Script to Launch Program with High Priority

Hi everyone, I have a favor to ask...

But first let me explain the situation:

I just ran across this wonderful free-app that, while it runs, monitors your processes and sets them to run at your defined process priority.

http://www.snapfiles.com/get/processmaster.html

Process Master is a tool for advanced users, that enables you to automatically adjust the process priority based on the process name. Simply run the program, select the process to be adjusted from the list, and select a priority level. Whenever the process is run, it will automatically use the designated priority level. Useful to manage CPU intensive applications.

I couldn't believe my luck as I have been looking for a tool to do this for ages. it works like a charm, except for one thing: it is a bit CPU intensive since it continually checks processes, (you can change the check interval, but I really wish I could just find a program that, upon another process starting, said program would set that process to a defined priority upon first load, once.

The reason I want to use a program such as this is I wish to set "YzShadow" and "TopDesk" to load at Windows Startup as "High Priority" Processes.

I found this quote:

If you're running processes at different priority levels, probably the best way to do this regularly was with a batch script and the start command - this program makes this process much easier, and gives it a GUI frontend.

So I was wondering, could someone show me how to write a batch script (for windowsXP) that I could launch at startup, that would in turn, launch TopDesk (for instance) and set it at a high (or real-time) priority? Or possibly provide me a sample script?

Thanks in advance,

~fc.

#308914

I've made you a simple commandline utlity, just for the kicks of it (I tried to make it really small in filesize, by not including the CRT :) ).

Source-code included. The code has more bytes than the executable file :o :cool:

http://mpj.tomaatnet.nl/PriorityLauncher.zip (1Kb utility)

Starts an executable with a different base priority

start with

PriorityLauncher.exe ?P $file_to_start

parameters (these parameters are CASE SENSITIVE and ORDER DEPENDANT,

eg. the ? must always come befre the $)

?P (priority level)

P can be one of the following:

- N normal

- H high

- R realtime

- L low / idle

$file_to_start

after the $ you can enter anything you want to start, including parameters

for the new process.

Example usage:

PriorityLauncher ?H $notepad.exe

will launch notepad.exe with a high priority level.

--

Andreas Verhoeven,

17 Augustus 2005

#308929

Try using the start command.

Create a batch file and add this to it

start /high C:Program FilesblahblahpathTopDesk.exe

start /high C:Program FilesblahblahpathYzDock.exe

Edit the paths to reflect where the applications are located. You can also try the abovenormal priority instead of high. Also I would not recommend using realtime priority. It will **** up your system. Use at your own risk.

EDIT: Freaking Ave beat me to it. :slant:

#308931

I get home, start doing my homework on Batch-files & HowTo's..

..30minutes later (I like reading up a bit ;) ) I create this and test it out...

(using notepad and naming the file to [some_name].bat)

@ECHO OFF



REM **********************************

REM Firecracker's Batch File

REM Start programs under defined priorities

REM Place this .bat file in your startup folder

REM Instead of your program's shortcuts

REM **********************************



REM Starts TopDesk with a "High Priority"

start /HIGH E:"Program Files"TopDesktopdesk.exe



REM Starts YzShadow with a "High Priority"

start /REALTIME E:"Program Files"YzshadowYzShadow.exe



:EXIT

It works; I come back to Aqua-soft to report my success and I'm greeted by Ave and Sid to the rescue :)

Dam* Ave, you just made my day, night, and gave me a late birthday present with this one! it works like a charm!! and preemptively eliminated my concern about the above batch file and how to run the script without having the cmd window flash on the screen momentarily. (Is there a way to run a batch file "silently"?)

@Sid, thanks for the info! I did a help on the syntax of start and noticed the /wait parameter... I was hoping this would allow me to launch a program with a high priority, have the the script wait until it has fully loaded, before proceeding to the next command line and load the 2nd app etc... But it actually waits for the program to terminate before proceeding which of course, does not work with what I was trying to accomplish.

Is there any way to accomplish this? The goal of which is to have control of which apps load before proceeding to the next app in line etc. Maybe even have less fragmented memory? (guessing)

EDIT: I wonder if you could call individual batch files (each starting a single program) using "Start /wait" from another batch file, I wonder if this could accomplish what I was wanting... or better yet, use a batch file to call Ave's PriorityLauncher in the above fashion.. but that takes me back to the momentary flash of the cmd window when running the batch file issue .. :P

For those DIYers, I also found a neat way of using a shortcut to accomplish the batch file method, see screenshot:

anotheralternative7wf.th.jpg

But with Ave's Small (in memory) PriorityLauncher app, you can have twice the fun, in half the time ;)

Some useful links during my search:

Batch Command Descriptions

Nice Background/Guide and Samples

"Batfiles -The DOS batch file programming handbook"

Thanks again, Andreas & Sid!

Oh, Ave, I posted over at Neowin at the same time as here, i linked back to this thread so that there'd be closure over there... is it all right to direct traffic to your contribution? If not, I'll remove the reference to this thread from that post :)

#308975

To prevent the cmd window from showing up maybe instead of adding the batch file to the Startup folder, you could put a shortcut to the batch file. Then under the shortcut Properties choose Run 'Minimized' instead of 'Normal Window' so that it won't show up on the screen. ;)

#308988

you can have the batch file ping back for a delay in between the apps loading to ensure it starts up and then the next one can:

PING 1.1.1.1 -n 1 -w 2000 >NUL

change the 2000 to whatever delay you want (1000=1 second)

that's how i did a batch file a while back for an app installer... it pauses to make sure the last app installed is completely finished and can move to the next one without 2 things trying to install at the same time...

here's an excerpt to show you what i mean:

REGEDIT /S %CDROM%Fontinstall.reg

PING 1.1.1.1 -n 1 -w 1000 >NUL

ECHO.
ECHO Applying Registry Tweaks...
REGEDIT /S %CDROM%RegTweaks.reg

PING 1.1.1.1 -n 1 -w 2000 >NUL

ECHO.
ECHO Installing Neowin UXTheme Multi-Patcher
ECHO Please wait...
start /wait %CDROM%ApplicationsUtilitiesNeowinPatcherUXTheme.exe

PING 1.1.1.1 -n 1 -w 1000 >NUL

ECHO.
ECHO Installing Adobe Acrobat 7
ECHO Please wait...
start /wait %CDROM%ApplicationsUtilitiesAcrobatsetup.exe

PING 1.1.1.1 -n 1 -w 1000 >NUL

etc.

#308989

@Sid, nice idea ...lol I could maybe even use the shortcut I created in the screenshot in that same fashion.. EDIT: works nice! Thanks again.

@wookietv, thanks for sharing the excerpt... does this method simply add a delay for an amount of time one would expect the app to compete installation within? Or is there something more to it.. By the way, how did the app installer go? Did not adobe acrobat, interrupt with it's installation wizard windows?

Me starts thinking of ways to automate re-installs of my OS.

#308996

The reason I want to use a program such as this is I wish to set "YzShadow" and "TopDesk" to load at Windows Startup as "High Priority" Processes.

hi firecraecker6,

i have another question...

Why you want this two apps run with high priority? I use both too, so maybe it was also a good tip for me... :-)

thanx

from

cysco

#308997

@wookietv, thanks for sharing the excerpt... does this method simply add a delay for an amount of time one would expect the app to compete installation within? Or is there something more to it.. By the way, how did the app installer go? Did not adobe acrobat, interrupt with it's installation wizard windows?

Me starts thinking of ways to automate re-installs of my OS.

the delay is put in after the app is finished installing... so it doesn't necessarily extend the installation time, just an x amount of time added on after the installer...

the way i put the installer together is with full user control, allowing the wizards to appear... i want to decide where to install specific apps. you can, however, make it completely "silent" by adding switches to the end of the statements. this will make it install the app automatically in the default location with the default settings provided by the installer (e.g. c:program filesapp)

each installer program uses a different set of switches, so you have to know which one the app is using (e.g. acrobat uses installshield). so the silent acrobat line would be:

start /wait %CDROM%ApplicationsUtilitiesAcrobatsetup.exe - s

(there's actually more to it than just using the switch for installshield installers, but i'm not going to put the whole instruction here)

you can find out more about the whole thing here:

http://unattended.msfn.org/intermediate/apps/intro.htm

i can post a copy of the whole batch file if you want to see it

#309003

@cysco, well, with TopDesk , using visual styles, (and not WB Skins (windows flicker too much regardless when used with TD),) setting TD to a higher priority seems to substantially reduce an issue where, with live previews enabled, you see a window's frame momentarily go black, and back again. Sometimes windows show up black where a 'screenshot' would be in expose mode. I rarely, if ever, see those black windows now. But setting it's priority to high each reboot was getting old. Mind you, I have a decently spec'd machine so I don't seem to experience any problems running at high. With a dual-proc system, I've heard you can set to real-time without worry of locking as some report happens on single cpu systems. I wonder how hyperthreaded, and dual-core cpu's fare?

With YzShadow I'm not positive of a performance gain. Windows seem to be snappier, my logic being that the app gets a higher precedence to re-draw the shadows...

I did discover something cool though, in the past, i used to have YzShadow disable shadowing while moving windows since, with Visual Syles, a window in motion would leave a nasty streak of window artifacts across the one below. But if you use WindowBlinds with Hyperpainting enabled, and set to an aggressive setting, and enable YzShadow to draw shadows on moving windows, you get this beautiful crisp clear edge w/shadowed windows even during the most violent of window motions. It's beautiful. NIce work Stardock/WindowBlinds Crew!

A nice graphics card and system is required though, and with slower machines, you can still get the clean edge, but a slight lag is introduced when clicking (and gripping) a window to drag across the screen. You notice this when you click and instantly pull the window (it takes a moment to catch up,) verses when you deliberately and calmly click, then move the window (which makes the lag a lot less noticeable.)

Anyways, YzShadow was just an app I plucked outta the air for an example. Another would be to launch kKMenu. Set this sucker to high and it just slips and slides... quite fun.

whitestripanono0808052wc.th.png

Now with everyone's help here, i have the chance to think about what I would do with my system using PriorityLauncher, etc.. I'm sure I'll come up with some more apps which could benefit.

@Wookietv, I'd like to see your batch file, thanks :) Will check out your link as well. EDIT: dam*, nice link. This'll surely make my girlfriend regret ever dumping me

#309005

here's a zip file with the batch file, and 2 registry files it references... it shows how you can also have it automatically install fonts for you (batch file copies the fonts to the fonts folder and then the registry file merges it onto your system)

just change it up to what suits you... if you have any recommendations on how i can make it better, by all means... i realized that some of the software versions it shows is out of date, i haven't played with this in a little bit.

enjoy.

Applnstaller.zip

Attachment: Applnstaller.zip

#309015

Thank! Going to sleep now, I'll take a look through it tomorrow

#309017