Login  * FAQ
It is currently Sun May 19, 2024 8:48 am

All times are UTC + 1 hour




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Basic batch file guide
PostPosted: Wed Feb 21, 2007 3:28 am 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
I mentioned in the Lites forum a while back that I created a batch file that allows me to stop all unneeded programs and background services and start NR2003 in high CPU priority mode all with just one click. Well I mentioned I might make a guide on how to do it if anyone was interested and someone reminded me of this so here it is.

I apologise in advance, its very long but I wanted to make it simple enough for someone with no batch file knowledge to follow:

These instructions are for XP Home but will/should work fine for XP Pro also:

First you need to download a utility called PSKill as XP Home doesn't have a working task kill command. Get it here:

http://www.microsoft.com/technet/sysint ... skill.mspx

It comes in a zip folder called PsTools, just cut and paste the PSKill exe to your C:\Windows folder (doesn't need installing) and delete the rest of the PSTools folder you downloaded.

A batch file is basically just a notepad file with a list of commands that are run when you click on it.

Step 1
So open notepad and we will start to create a list of programs and services to end before starting NR2003.

The first line to add to the notepad file is:

@echo off

Don't worry about what that does, just put it at the start of the notepad document (it'll save you seeing a load of unnecessary waffle when you eventually start using it).

Step 2
First you want to stop any open programs that you don't need when racing. This is anything you know is open that you want to stop every time you run this, this includes anything that may be running in the system tray (bottom right of screen, next to the clock). You can include anti-virus if you know you will restart it afterwards, but not firewall.

We do this by using the following command:

pskill -t Program.exe

To find the programs exe name click ctrl-alt-delete to open Task Manager and you should be able to find it under the processes tab. For example I have a temperature monitor called HDTune which shows my system temp in the tray. When I ctrl-alt-delete and look under the processes tab I find a process called HDTune.exe, so the command I would use to end that program would be:

pskill -t HDTune.exe

If you are uncertain which process it is, you can check what most processes are here:

http://www.processlibrary.com/
http://www.castlecops.com/slet-d.html

So now you should have a notepad document with the first two lines of your batch file:

@echo off
pskill -t example.exe

Repeat step two for any other programs you want to add. To give you an idea of what it should look like my batch file at this point would look like this(yours will have different program names):

@echo off
pskill -t dslstat.exe
pskill -t HDTune.exe
pskill -t avgcc.exe
pskill -t AOLacsd.exe

Step 3
Now we have added the programs we want to stop we can make a start on stopping background services, this will take a little more time, especially if you've never disabled any background services as you may have ALOT running.

The command we will use for stopping these services is:

Net stop "Service name"

To see the services running on your computer go to Start>Run and enter 'Services.msc'. This will bring up a list of all services on your computer including those that are running and those that are not. The only ones you have to worry about dealing with are those whose status is 'Started' OR those whose Startup Type is listed as 'Automatic'.

When you highlight one it should give you a brief description of what it does on the left of the window, this may be enough alone to decide if you don't need it running while your playing NR2003. About 95% of the services you don't need to just play NR2003 (the most important ones usually can't physically be stopped anyway).

If the description alone isn't enough try looking up the service on one of these sites, they also give recommendations on whether they need to be running:

http://majorgeeks.com/page.php?id=12
http://engr.smu.edu/~kaytaz/xpservices.html

You can always be cautious with which services you add to the batch file and add more later.

So, to create a command to stop a service go to Start>Run enter services.msc to bring up the services list (if it isn't still open). Right click the service you want to add, select 'Properties' and copy the 'Display name' exactly as written in Properties. Enter the Net stop command as the next line of your notepad file:

Net stop

followed by the services display name wrapped in quotes. For example to stop the Automatic updates service the command would be:

Net stop "Automatic Updates"

Repeat step 3 for every service you want to add. Once again to give you an example of what it should look like this is what my notepad file would be looking like at this point (yours will probably have different, or more/less, service and program names):

@echo off
pskill -t dslstat.exe
pskill -t HDTune.exe
pskill -t avgcc.exe
pskill -t AOLacsd.exe
NET STOP "Automatic Updates"
NET STOP "AVG7 Alert Manager Server"
NET STOP "AVG7 Update Service"
NET STOP "Cryptographic Services"
NET STOP "DHCP Client"
NET STOP "inadyn"
NET STOP "Infrared monitor"
NET STOP "Windows Firewall/Internet Connection Sharing (ICS)"
NET STOP "Network Connections"
NET STOP "Network Location Awareness (NLA)"
NET STOP "Print Spooler"
NET STOP "Protected Storage"
NET STOP "Removable Storage"
NET STOP "Shell Hardware Detection"
NET STOP "Task Scheduler"
NET STOP "Themes"
NET STOP "Windows Image Acquisition (WIA)"

If you've got this far WELL DONE, thats the hardest bit done and we're nearly finished :)

Step 4
Next up is the line to start NR2003 with high CPU priority. This looks a bit strange but is really straighforward. Mine is this:

START /high C:\Papyrus\NASCAR~1\Nr2003.exe

If you have NR2003 installed in the default location the only thing you might need to change is the drive letter - mine is C, just change it to whatever your hard drive letter is.
Then just add the 'Exit' command to close the batch file:

START /high C:\Papyrus\NASCAR~1\Nr2003.exe
EXIT

That is the basic batch file finished. Now you just have to make sure you save it correctly or else it won't work. Click 'File' (at the top of notepad) and 'Save as...'. You can name it whatever you want, but you MUST end the name with .bat. Also before saving click the 'Save as type' dropdown box and change it to 'All files' (NOT .txt) - THIS IS IMPORTANT (it won't work otherwise)

When its saved it should have an icon like a window with a cog in it, not the regular notepad icon. If it has the regular notepad icon you haven't saved it right.

Now your ready to try it. Simply double click it. A command window should open showing the programs and services being stopped and when thats finished NR2003 will start (and in high priority mode) :)

EDIT: Remember you can always add more services or programs to the batch file once its finished by right click>Edit ;)

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 3:29 am 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
The above is fine for stopping the programs and services but what about restarting them. Well the easiest way is just to restart your PC after you've finished the game, I do this anyway as our computer tends to run slow for a few minutes after playing. But if you don't want to restart after every time you play you can very simply modify your batch file to allow it to restart all the services and programs after you close NR2003.

First you need to alter the final two lines of your original batch file from:

START /high C:\Papyrus\NASCAR~1\Nr2003.exe
EXIT

to:

START /high /wait C:\Papyrus\NASCAR~1\Nr2003.exe

Note the addition of the /wait command and the removal of the exit command. This is because we will be continuing the batch file so don't want to exit, and the /wait command will pause the batch file after the NR2003 command. It will then carry out the following commands after you close NR2003.

So to restart the programs use the 'Start' command but you also need to use the full file path to the programs exe file. So, for example if I wanted to start HDTune on my computer it should be (though it isn't):

Start C:\Program Files\HD Tune\HDTune.exe

BUT that won't work as Windows won't understand the space. If theres a space in part of the file name, as in 'Program files' you use the first six letters then add ~1 so the correct way of writing it would be:

Start C:\Progra~1\HDTune~1\HDTune.exe

Do the same for each program you want to restart.

Then you want to restart the services, this is simple. Just copy and paste the lines from the first half of the batch file - the ones starting with 'NET STOP', and replace all the 'NET STOP's with 'NET START'.

Then just add EXIT to the end and save it and your done. The batch file will now restart all the programs and services as soon as you exit NR2003 :)

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 3:33 am 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
If anyone tries it and has any problems let me know and I'll be happy to help. Or if you try making a batch file and it doesn't work, post it here (or PM it to me) and I'll check through it for any problems :wink:

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 9:10 am 
Offline
1000+ posts! I'm a V8T nutter!
1000+ posts! I'm a V8T nutter!

Joined: Thu Mar 16, 2006 7:25 pm
Posts: 1849
Location: Vienna
WOW! (not vista related), great stuff JP! Will try to get one running asap. Even it only includes one or 2 services....but thats a nice thing, and exceptional well explained, really impressed here!

MZ

_________________
Team Boss of Epix Racing Team
http://epixracing.com
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 4:23 am 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
Cool, my first ever sticky. Glad the time I spent writing it wasn't in vain :lol:

And as I said, any problems don't hesitate to ask. Already had one PM asking me to check a batch file that was spot on so at least I know the guide works :D

PS Thanks for the compliment MZ :wink:

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 4:15 pm 
Offline
Site Admin
User avatar

Joined: Tue Mar 14, 2006 9:36 pm
Posts: 1430
Location: Northampton, UK (Motorsport Valley)
Very useful John, especially those links to the info on services running.

Will have to try it out. Am pretty sure it should work similarly on Win2k as it does on XP.

:D

_________________
#98 Jonathan 'JR' Rex

RexRacing.co.uk - virtual race car driver for over 40 years


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue Jan 08, 2008 4:36 pm 
Offline
Pole Sitter
Pole Sitter
User avatar

Joined: Fri Aug 31, 2007 3:23 pm
Posts: 408
Location: Lake District, UK
JDPower wrote:
BUT that won't work as Windows won't understand the space. If theres a space in part of the file name, as in 'Program files'


Im pretty sure you can use quotes round the path name even in DOS and with batch files.

so you can do thinks like :-

START /high /wait "c:\Papyrus\Nascar 2003 season\nr2003.exe"

or whatever you path is.

Jeff

_________________
#61 Jeff Johnstone, Whirlwind Racing


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 08, 2008 5:36 pm 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
jethro10 wrote:
JDPower wrote:
BUT that won't work as Windows won't understand the space. If theres a space in part of the file name, as in 'Program files'


Im pretty sure you can use quotes round the path name even in DOS and with batch files.

so you can do thinks like :-

START /high /wait "c:\Papyrus\Nascar 2003 season\nr2003.exe"

or whatever you path is.

Jeff

Yeah that works too, I just find the way I do it shorter and more efficient and I seem to remember having a problem with putting the name in quotes before.

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Mon Jan 26, 2009 7:56 pm 
Offline
1000+ posts! I'm a V8T nutter!
1000+ posts! I'm a V8T nutter!
User avatar

Joined: Wed Apr 30, 2008 5:17 pm
Posts: 2422
Location: Stadskanaal
i start nr2k3 from out the Logitech G25 profiler. So i can't put it in the batch.


Top
 Profile E-mail  
 
 Post subject: Re: Basic batch file guide
PostPosted: Mon Jan 26, 2009 10:07 pm 
Offline
Pole Sitter
Pole Sitter
User avatar

Joined: Fri Aug 31, 2007 3:23 pm
Posts: 408
Location: Lake District, UK
Erwin Greven wrote:
i start nr2k3 from out the Logitech G25 profiler. So i can't put it in the batch.


No, but you can put it all in a "stop.bat" batch file on your desktop and double-click it before you run via the Profiler

J

_________________
#61 Jeff Johnstone, Whirlwind Racing


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Wed Aug 26, 2009 10:21 pm 
Offline
1000+ posts! I'm a V8T nutter!
1000+ posts! I'm a V8T nutter!
User avatar

Joined: Thu Mar 23, 2006 5:26 pm
Posts: 2478
Location: Lichfield
Does anyone know if theres a command to disable (and thus stop) a service using a batch file.

Ive found out that the only way to stop AVG8 is to kill the tray process, then disable the AVG service, before killing the other bits of AVG software. If the service isnt disabled, it simply restarts as soon the process is killed!

My code so far is;

@echo off
pskill -t avgtray.exe
net stop "AVG Free8 WatchDog"
pskill -t avgwdsvc.exe
pskill -t avgnsx.exe
pskill -t avgrsx.exe
EXIT


The way it was explained in a forum i read is to right click the AVG Free8 WatchDog service, click properties and then Disable (not manual).

Anyone?

_________________
image

#28 Steve Pearce

R.I.P Colin McRae, you were a Legend!

Colin Mcrae: 1968 - 2007

Everyone who ate an apple in 1869, is now dead!


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Wed Aug 26, 2009 11:23 pm 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
LessThanSte wrote:
Does anyone know if theres a command to disable (and thus stop) a service using a batch file.

Ive found out that the only way to stop AVG8 is to kill the tray process, then disable the AVG service, before killing the other bits of AVG software. If the service isnt disabled, it simply restarts as soon the process is killed!

My code so far is;

@echo off
pskill -t avgtray.exe
net stop "AVG Free8 WatchDog"
pskill -t avgwdsvc.exe
pskill -t avgnsx.exe
pskill -t avgrsx.exe
EXIT

Steve use the following command AFTER the net stop "AVG Free8 WatchDog" line:

sc config "SERVICE NAME" start= Disabled

Use the actual service name (I assume its "avgwdsvc"), ie when you look in the services list (services.msc) right click the watchdog service, click properties and copy the actual service name, not the display name. You won't need the "pskill -t avgwdsvc.exe" line then.

So you should have (unless I cocked up somewhere):
@echo off
pskill -t avgtray.exe
net stop "AVG Free8 WatchDog"
sc config "avgwdsvc" start= Disabled
pskill -t avgnsx.exe
pskill -t avgrsx.exe
EXIT


To set it back to automatic use:

sc config "SERVICE NAME" start= Auto

Or to set it back to manual:

sc config "SERVICE NAME" start= Demand

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Thu Aug 27, 2009 12:06 pm 
Offline
1000+ posts! I'm a V8T nutter!
1000+ posts! I'm a V8T nutter!
User avatar

Joined: Thu Mar 23, 2006 5:26 pm
Posts: 2478
Location: Lichfield
Seems to have done the trick, thanks John :)

The code i had is actually as follows;

@echo off
pskill -t avgtray.exe
net stop "AVG Free8 WatchDog"
sc config "avg8wd" start= Disabled
pskill - avgwdsvc.exe
pskill -t avgnsx.exe
pskill -t avgrsx.exe
EXIT

_________________
image

#28 Steve Pearce

R.I.P Colin McRae, you were a Legend!

Colin Mcrae: 1968 - 2007

Everyone who ate an apple in 1869, is now dead!


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Wed Sep 02, 2009 11:04 am 
Offline
1000+ posts! I'm a V8T nutter!
1000+ posts! I'm a V8T nutter!
User avatar

Joined: Thu Mar 23, 2006 5:26 pm
Posts: 2478
Location: Lichfield
Right, how about this!

Is there a way to make a little box pop up when i run the above script, with a button that can be pressed when i want to restart AVG, to save me from having 2 seperate batch files?

_________________
image

#28 Steve Pearce

R.I.P Colin McRae, you were a Legend!

Colin Mcrae: 1968 - 2007

Everyone who ate an apple in 1869, is now dead!


Top
 Profile  
 
 Post subject: Re: Basic batch file guide
PostPosted: Sun Oct 25, 2009 3:36 am 
Offline
Racing For Position
Racing For Position
User avatar

Joined: Thu Mar 23, 2006 11:56 pm
Posts: 878
Location: Corby, Northants.
LessThanSte wrote:
Right, how about this!

Is there a way to make a little box pop up when i run the above script, with a button that can be pressed when i want to restart AVG, to save me from having 2 seperate batch files?

Sorry for the long delay replying, not been around here much and for some reason never got an email to tell me you'd posted a reply.

If there is a way of doing that it's beyond my knowledge. Are you using this just to stop the processes whilst running a game? If so you don't need to have two batch files, just use the batch file to launch the game using the 'wait' command after the stop services section as suggested in the guide:
Quote:
START /high /wait C:\Papyrus\NASCAR~1\Nr2003.exe

Note the addition of the /wait command and the removal of the exit command. This is because we will be continuing the batch file so don't want to exit, and the /wait command will pause the batch file after the NR2003 command. It will then carry out the following commands after you close NR2003.

That way you have the first batch section that stops services, then launches NR2003, waits till NR2003 is exited then will run the commands to restart everything.

If that makes no sense let me know and I'll answer more coherently when I've got a less tired head lol

_________________
#5 Rammstein Chevy
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
 [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron




Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
© 2008 V8Thunder.