Program to start things in LOW priority?

Nazo

2[H]4U
Joined
Apr 2, 2002
Messages
3,672
Well, I've recently discovered that you can use start to do this with NT (XP, 2K) but the problem is that, at least with XP (don't know about 2K or below) start is not an actual executable, but, a command known only to the console command interpreter (cmd.) This is rather bothersome. Does anyone know of a FREE program that can do such a simple thing without having to go through cmd? I've found a couple of commercial things with a bunch of extra stuff and they don't even directly run the program, but attempt to set it to low after you've run it.

As for why I'd like to do this, there are several programs -- such as the weatherpulse program I used to use (found better) -- which just love to eat up free cycles sometimes. Terribly annoying when you are trying to play games that rely heavily on the CPU like Far Cry...

BTW, for those who don't know, the syntax to start things like this is simply add the priority name after start like so:
START /LOW C:\TEST\TEST.EXE
But, to run it through the registry or start menu, you have to first open the command prompt:
CMD /C START /LOW C:\TEST\TEST.EXE
Unfortunately, you run into issues with things like quotes. And I can't very well go through and set EVERYTHING to use only short filenames. It becomes quite tedius after a while. And it's very hard to find out the real short filename in windows (harder yet in dos since you don't get to see the long filename next to it...)
 
If I am understanding this correctly, you want to run a program on startup that is automatically set to low priority. Is that correct? If so, couldn't you just drop it in the startup folder and let it run from there? Granted, you would have to do this with every program that you wanted to run like that, but I can't imagine that there would be too many.

Cheers.
 
A few things needed to be started in the registry so they are there sooner. Also, in a few poorly made cases, the program will look and see no entry is present, so add it back so that you then have it trying to run twice.

Anyway, I'm still having troubles EVEN IN THE START MENU when I use the method I already know. As I said, you run into issues when it comes to things like quotes (needed for a few things such as long filenames like when I'm passing a variable filename as a paramater or a number of other things) and paramaters are just a pain beyond reason. And, in one case, for some reason I can't quite decipher yet, it actually just opens a plain command prompt with the TITLE of the program rather than actually starting the program. Regardless, it's just plain easier if I had a real program, something with .exe at the end, rather than having to do something that for some unkown reason was made to only be used in the console.

I may try to rig up something in a batch file, but still one tends to run into issues there too. And it's annoying that it wants to open up a console each time, wasting resources and just being annoying in general by popping up in my face. What I REALLY want, is something that runs natively. Much cleaner, more efficient, and no annoyance that way.
 
Still no ideas?

Well, I've given up on searching. I guess the only thing I can do is make my own. Problem is, I'm not THAT good of a programmer...

First of all, I think I read somewhere that if you set the priority of something then anything that particular program starts will be the same priority. Is this true?

Oh well, either way, if I ever get it completed I'll find out for myself.
 
Nazo said:
Still no ideas?

Well, I've given up on searching. I guess the only thing I can do is make my own.

The reason you can't find anything is that you don't need a program. Just use the START command from the command line, and give it the /LOW option or the /BELOWNORMAL option. For notepad:

Code:
start /low notepad

and you're there. If you want to do this from a shortcut in the Start menu or an icon on the desktop, you can either have the shortcut run a batch file that has this command, or run CMD.EXE to ask it to do this command. The Start command is built-in to CMD.EXE.

Code:
cmd /p start /low notepad

does the trick.

Nazo said:
which just love to eat up free cycles sometimes. Terribly annoying when you are trying to play games that rely heavily on the CPU like Far Cry...

If such a program interferes with something else that's running, it's not using only free cycles.

Nazo said:
First of all, I think I read somewhere that if you set the priority of something then anything that particular program starts will be the same priority. Is this true?

Kind of, but not strictly. Read the documentation for the CreateProcess API to see what the rules are. But in short, you specify the priorty -- and you can specify a priority that is "default", which means the new process might get the same priority as the process calling CreateProcess().

.B ekiM
 
*sigh* Please read the thread before responding. I already explicitely stated that I had done it the way you suggested and explained the problems with that particular method as well as why it wouldn't work for my purposes. I mean, geez, look up, it's in the first thread...

Anyway, I've already been playing around with making such a program. I just got fed up with it. I don't know if I'll get back to it or not after going through such an uphill battle. Anyway, yes, I definitely found out that when you start a new program like that it does not have the same priority normally. That will make things a good deal more complicated since I have to get the process id or whatever (haven't found the appropriate way to do this just yet.) It's the only way to be sure though.
 
Nazo said:
*sigh* Please read the thread before responding.

Whoa! Sorry, I don't know how I missed that.

Nazo said:
Unfortunately, you run into issues with things like quotes.

What specific issues are you running into? Why do you think you need to use short filenames for everything?

Nazo said:
That will make things a good deal more complicated since I have to get the process id or whatever (haven't found the appropriate way to do this just yet.) It's the only way to be sure though.

Why? Do you not always want the new process to be running low priority? Why does the priority of the starting process matter to you?

.B ekiM
 
Oh, it's easy to get the id of the current process. I meant it would be hard to get the id of the process being started. I actually sucessfully managed to get the current process priority to be changed, but, whenever it started another process through more normal methods than the start process command (can't recall what I used, maybe windows shell) the second program would be normal priority.

As for short filenames, before I thought that was the reason for the fact that it would sometimes just open a console with the filename as the title (also discussed before.) However, I corrected that and it still does, so I guess that's not it after all. I can't find any consistancy in the reason that some do that and others don't. So far the closest I can tell is that it has troubles with passing quotes due to the way the whole thing works, but by eliminating long filenames, I was able to eliminate the quotes, so I'm just not sure anymore. All I know is that basically the problem comes down to the fact that if I'm not running cmd in the first place, it won't do this. It's that simple.
 
Nazo said:
I meant it would be hard to get the id of the process being started.

It's not hard at all. The CreateProcess() API returns it to you.

Nazo said:
I actually sucessfully managed to get the current process priority to be changed,

Why do you want to change the priority of the current process?

Nazo said:
whenever it started another process through more normal methods than the start process command (can't recall what I used, maybe windows shell) the second program would be normal priority.

So, you're changing the current process priority in the hopes of affecting the newly started process priority? Why not just specify the priority you want for the new process in the call to CreateProcess()?

Nazo said:
(also discussed before.)
Yeah, I saw you mention this. I couldn't figure out what you were talking about.


Nazo said:
As for short filenames, before I thought that was the reason for the fact that it would sometimes just open a console with the filename as the title [...] However, I corrected that and it still does, so I guess that's not it after all. I can't find any consistancy in the reason that some do that and others don't.

Sounds to me like the reason is that you're giving the wrong parameters to START. If you do START /?, you'll get this usage:

Code:
START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/WAIT] [/B] [command/program]
      [parameters]

Note that the first parameter is the title, which is encased in quotes. If you're using this command:

START "my program.exe"

then you're asking START to run CMD.EXE and put it into a window with that title. If you need quotes around the [command/program] paramter, you need to specify a ["title"] parameter. So something like this will do what you want:

START "" "my program.exe"

If you need to specify parameters, go ahead and do so:

START "" "my program.exe" "my file.txt" /AnotherOptionForMyProgram "your file.dat"

and you're there.

.B ekiM
 
well I dont know of any free programs that would do it
but I do know of a program that is worth its price that will

Taskinfo 2003 shareware, worth a spin, has helped me resolve more issues than any other ap Ive got
 
I may look, but, I'm quite broke, so I'd have to use it in limited mode (which probably means a horribly annoying popup or something at least) and that sort of thing.

Anyway, I'm guessing I'll have to stick to making my own program. I'm definitely going to dig through that API, but, I have to get the rest of it working first I suppose. BTW, is there some easier way to parse commandline options than writing my own thing from scratch? Seems like there should already be a header or something in place for this. Of course, it has to work with windows properly (meaning / is a switch rather than directory, or at the least use - instead...) I'll have to change to the target directory if I can just to be on the safe side. Windows usually executes programs inside their own directory, but that means that this program would execute other stuff within it's own directory unless I change manually. I sure would love an easier way to sort out the commandline paramaters, directories, and so on.
 
Nazo said:
Anyway, I'm guessing I'll have to stick to making my own program.

Why? START does what you want, as far as I can tell.

Nazo said:
BTW, is there some easier way to parse commandline options than writing my own thing from scratch?

Probably. Which language are you using?

.B ekiM
 
I told you, I TRIED using start. I keep ending up with, instead of the program I told it to run, an open console window with the title that shows the path and filename to the program I wanted to run. BESIDES, I don't like having to load command and use it to run something that could much more quickly and efficiently be done through a real program.

Now, as for which language, C++. Other than VB, it's the only thing I really know how to do more than a hello world application with. Not that I'm exactly what you'd call very good. Also, partially I use stuff like this as just an excuse to learn a little bit more. I wish I could just throw together programs that do simple things like this, but it seems like I just don't know it well enough and don't use it enough to ever learn enough. Heck, I still have trouble STARTING with pointers. I should have that basically down by now.
 
Nazo said:
I told you, I TRIED using start. I keep ending up with, instead of the program I told it to run, an open console window.

Those symptoms mean you're giving START the wrong parameters. If my previous posts weren't clear, let me know and I'll explain it again.

BESIDES, I don't like having to load command and use it to run something that could much more quickly and efficiently be done through a real program.

I don't think loading CMD.EXE for this is going to be measurably less efficient. After your program starts, CMD.EXE is going to leave memory. The cost of loading, initializing, and running CMD.EXE is not going to be very much.

Or is it that you plan to run thousands of processess again and again in a loop?

Nazo said:
Now, as for which language, C++.

C++ starts your program at a specific entry point. That entry point for a console application is called main(). main() will receive two parameters; a count of arguments and an array of pointers to the arguments. The first thing you'll program will need to do is make sure it has enough arguments and print an error if it didn't.

Then, it will need to take those arguments and get them into a state which is good for passing to that CreateProcess() API. You'll need to do some work with pointers, so if you're very uncomfortable with them, you'll have some learning ahead of you.

.B ekiM
 
I DID give start the correct parameters. The funny thing is that the program that does this every time is one of the few that don't pass paramaters to the program itself. The others seem to just do it sporadically, or at least I haven't found the pattern yet. Also, bear in mind that it's the CONSOLE WINDOW that has the title, NOT START. Start doesn't have a windows, so I don't understand the confusion here really though.

EDIT: Oh, and btw, I used copy and paste when adding the part to load them that way, so they all had the exact same setup. No typos.

As for where command is a problem, it's not the memory. I have 1GB which is more than sufficient for a gaming machine at this time with junk running in the background. Remember, this stuff is being run on startup whether in the registry or the start menu. That makes it take even longer to load up enough to actually DO anything (sure you can see the desktop, but when you get no response from any clicks or keys, I don't count it.) Cmd isn't particularly fast since it likes to eat cycles for timing or something, so it doesn't matter that much how fast your CPU is in fact apparently.

About the whole C++ thing, I kind of already knew that much.. I was asking if there is already something made to process this stuff. It's rather a lot of work to write a commandline parser if there's already one there. As for pointers, chances are I won't need more than one, and that just to the process I just started. Of course, if the API really can set the priority (which I will find out once all the rest is in place) then I won't need that after all.


Now, could we please stop restating the exact same stuff over and over about start? I've stated why I don't wish to use it in the first thread, then you just seem to say the same stuff over and over. Let's just consider that MAYBE there is a situation in which start ISN'T the best possible solution. Heck, let's say Win9x if it makes you feel better (yes, Win9x has priorities. While not perfect, it does make more sense to set something that wastes cycles needlessly to a lower priority and it is then less likely to interfere.)
 
Nazo said:
I DID give start the correct parameters.
If you really did provide the correct parameters to START, then why didn't it work? Maybe you should post the specific commands you're using here so we can all have a look.

Nazo said:
About the whole C++ thing, I kind of already knew that much.. I was asking if there is already something made to process this stuff. It's rather a lot of work to write a commandline parser if there's already one there.

Sorry, maybe I wasn't clear enough. The parameters passed to main() give you an already parsed command line. Each pointer in the array you get points at a separate string containing the next argument given in the executable's command line. There's not much more work you need to do yourself; just get cracking on the array.

But you say you kind of already knew about main() and its parameters. Which is odd, since you're asking again for something you already know.

Nazo said:
Cmd isn't particularly fast since it likes to eat cycles for timing or something, so it doesn't matter that much how fast your CPU is in fact apparently.

How did you reach that conclusion? Try this:

1) Open a command Propmt window.
2) Press CTRL+ALT+DELETE to bring up task manager
3) Activate the Processes tab
4) Make sure the "CPU" column is visible
5) Find the entry for CMD.EXE.

Nothing is running in CMD. It's using zero CPU. What in the world would CMD want to time? Why can't we see these cycles that you say it is burning?

If you really want to write a program, go ahead. Before you spent the time on it, I wanted to make sure you knew that it isn't necessary.

Nazo said:
As for pointers, chances are I won't need more than one,

You'll use far more than one, even in this simple application.

Nazo said:
and that just to the process I just started.

A pointer to the process is not the one of the pointers you'll use, though. Win32 identifies processes by handles and IDs, not by pointers.

Nazo said:
Of course, if the API really can set the priority (which I will find out once all the rest is in place) then I won't need that after all.

CreateProcess() really can set priority, believe it or not.

Nazo said:
Let's just consider that MAYBE there is a situation in which start ISN'T the best possible solution.

Sure; I suppose you might be able to find such a situation. It's just that you've offered nothing which makes me think your situation isn't appropriate for the START command.

Thing is, the START command was designed to do exactly what you want to do. That you're having trouble finding a program to do what START already does makes sense: since START already does it, why write a program?

.B ekiM
 
Are you trying to turn this into a flame war or something? JUST QUIT THAT ALREADY!

The paramaters I gave to start was start /low "c:\program files\powerstrip\pstrip.exe" or start /low c:\progra~1\powerstrip\pstrip.exe There, are you satisfied? AGAIN I point out, START DOES NOT HAVE A WINDOW!!! Therefore, it is not a matter of paramaters passed to start, now is it? As for cmd, I just did it the standard way, cmd /c start /low "c:\program files\powerstrip\pstrip.exe" and cmd /c start /low c:\progra~1\powerstrip\pstrip.exe However, bear in mind once again that this was copied and pasted from other things that worked both ways.

The compiler I used when I was learning merely passed an integer followed by a simple character array. So parsing had to be done by reading through the array one letter at a time and figuring out what to do with each letter. I haven't played around with command line paramaters since then to be honest, so maybe that has changed. If so, fine, I'll check it out.

As for CPU, ALL programs eat a little cpu time when you first start them. When did CMD become an exception to this? And why wasn't my copy informed? I don't care how much it is using after 5 seconds or so of running, I care how much it is using when about 10+ windows pop up at once!

Oh, and I HAVE given you a situation in which start wouldn't work. Just to give you an example (AGAIN) there's Win9x. And my extremely slow laptop just happens to have to use Windows 95 as a matter of fact, so I do work with Win9x on a regular basis. This is just a repetition of the last example. I won't restate the others, you'll just have to scroll up and actually read. Nonetheless, I just don't care what you think anymore. I've already stated a bunch of reasons why I prefer a less inefficient troublesome manner than having to go through two seperate programs that WEREN'T intended for this purpose, but, instead were intended for an administrator to do things such as telnet in and remotely do a few basic troubleshooting things. I don't understand why you just insist on nitpicking if I say left when I mean my left rather than yours. Just drop it. If you don't want to help, don't, but please stop leaving half page long explanations reminding me why I hate to ask people for help with simple little things. Thank god I'm not paying for THIS.
 
Nazo said:
Are you trying to turn this into a flame war or something?

Believe it or not, I'm trying to help you out.

Nazo said:
The paramaters I gave to start was start /low "c:\program files\powerstrip\pstrip.exe" or start /low c:\progra~1\powerstrip\pstrip.exe There, are you satisfied?

Thanks for providing me with some information to help diagnose the behaviour you're seeing. Were these commands that worked, or not?

For me, the first comand doesn't work. It results in a window that has a copy of CMD.EXE running in it, and the title "c:\program files\powerstrip\pstrip.exe". From what I've read in this thread, that's not what you want.

The reason you get that window is because you're using the wrong syntax for the parameters to START. If you use this command, instead:

Code:
start "" /low "c:\program files\powerstrip\pstrip.exe"

you'll find that it works just fine.

The second command doesn't pop up a new command window because the second argument you give it doesn't have quotes around it.

.B ekiM
 
Actually, yes it does. I told you, both with and without the quotes does that, so that didn't solve the problem.

Ok, now, this is the last time I say it. I have decided for multiple reasons already stated multiple times, I will not use start. I will not repeat this.
 
Nazo said:
I will not repeat this.

of course keeping in mind that mikeblas is typing his fingers into a bloody mess trying to help you

right?

:p

as a note on TaskInfo 2003
I cant remember what shareware limitations there are, sorry
 
Nazo said:
Actually, yes it does.

Sorry; what does what?

Nazo said:
Ok, now, this is the last time I say it. I have decided for multiple reasons already stated multiple times, I will not use start. I will not repeat this.

I'm sorry to see you take that choice, as I think you can get what you want with zero development work by using START.

Let us know how it goes with writing your application.

.B ekiM
 
Ice Czar said:
mikeblas is typing his fingers into a bloody mess trying to help you

I type pretty fast. It keeps my overhead low.

.B ekiM
 
here's a thought.. .

1. Create a new NOTEPAD
2. Type in..

CMD /C START /LOW C:\test\test.exe
CMD /C START /LOW C:\test\test.exe
CMD /C START /LOW C:\test\test.exe
CMD /C START /LOW C:\test\test.exe
CMD /C START /LOW C:\test\test.exe

etc...

3. Save As: startupLOW.bat
4. have that startup when windows start by putting it in startup folder in your start menu or registry key..

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

startupLOW REG_SZ C:\test\startupLOW.bat

tell me how that works: auayan AT comcast.net (MSN/EMAIL)

http://tehsyndicate.endignorance.com


-------------------------------------------------------------------
Edited to defeat email harvest bots ;) - Ice Czar
 
tsunami said:
tell me how that works:

It'll work great. But Nazo has decided he doesn't want to use START or CMD.

.B ekiM
 
OK well, for starters I have no idea if this is even applicable, or could be made applicable
but if its not useful in this case it might be elsewhere

Sustain

I had problems with a system service self terminating at random. I wrote this program to monitor and restart it when it died. Through command line parameters you can have it check for any program at any interval and run any program when not found. (Did that make sense?)

lots of other freeware aps at that site, I refered so many people to Wipeout that he started charging for it :p
 
I'm definitely checking that out. If nothing else, some of the other tools look nice. In particular, their task manager program sounds like a nice little tool. (Always HATED the way you can hit end task 50 times for some things, but they will never end until you log out/reboot...) It's even actually kind enough to tell you the whole location of the file and the PID. Can't help but wonder how this STOP program works to actually lock up Windows so completely you can't kill it or anything. I always thought only a hardware type thing could lock it up that thoroughly.

Eventually I'll get around to trying to write something. If nothing else, it's a good learning experience. I'd really like to some day know enough C++ to actually write useful little programs to do what I want when I run into annoyances like this.

BTW, reference to anyone who does follow that site. DO NOT USE THE SLAP PROGRAM!!! I'm not kidding about this. Use something like that and a potential hacker will take it personally. Once they do that, even a hardware firewall might not prevent enough from slipping through... You just can't beat the effects of a good silent firewall that makes it seem like your system doesn't exist to them.
 
Back
Top