Go Back   Project Reality Forums > Project Reality Mod Forums > PR Help and Hardware Support
PR Help and Hardware Support : Help and support regarding PR and computer issues.

Welcome to the Project Reality Forums! Join the Project Reality forums! Contact Us


Reply
 
LinkBack Thread Tools Display Modes
Old 02-21-2008, 01:01 PM   #1

-=x0(GHOST)0x=-'s Avatar
Free up RAM - automatically shutdown and restart systems services

So I stumbled across this concept the other day, and I'm so psyched about it that I just had to share it. Like most PR players, I try to free up as much RAM as possible before I start BF2. I'm a forgetful person, so I'm hesitant to shut down important services such as anti-virus or anti-spyware, because I usually forget to turn them back on once I quit the game. My solution has been to keep all of these process up and running, and just deal with the RAM reduction.

Until now.

The other day, I stumbled across the “batch file”. This is a windows tool that allows you to automatically execute commands from the command prompt. Batch files reach all the way back to the days of DOS, so this is not a new tool by any means. With a few simple command lines, you can automatically shut down any service you want (at your own risk, of course), and automatically restart the services once you quit BF2. Yes, I know. This is sweet.

Creating the Batch File
Creating a batch file is very simple. First, create a new ".txt" document using Notepad. You can name this file anything you want. Next, change the file extension from ".txt" to either ".bat" or ".cmd". The "command" file and the "batch" file extensions both do the same thing, so take your pick.

Adding the Code
I use the term "code" here very loosely. You don’t need to know any programming language or have advanced computer skills to do this. Adding the code to the batch file can be a little tricky, but it's not rocket science. You only need to know a few simple commands and parameters, but you do have to pay attention to detail. Just as with anything else in Windows, syntax counts.

The first two commands you need to know are “Net Stop” and “Taskkill”. As you might be able to guess, these commands both stop specific services or programs that happen to be running on your machine. I’m no expert, but as I understand it “Net Stop” only applies to Microsoft services that you find under Services.msc, while “Taskkill” will kill any running program. I just use Taskkill to keep everything simple. Here is the code that you should add to the beginning of your batch file:

taskkill /f /im [program name as written under the “Image Name” column of the Task Manager]

Example: taskkill /f /im EM_EXEC.exe

Example: taskkill /f /im ashMaiSv.exe

There are two important parameters here. First, the “/f” parameter forces the program to terminate without any confirmation dialogue whatsoever. Using this parameter shuts a program down no matter what it happens to be doing at the moment. Therefore, I don’t recommend using it for programs that require you to save changes (e.g. Microsoft Word). The “/im” parameter directs the batch file to look for the “image name” under the Task Manager. You can also specify other parameters, such as the “process ID” (/PID) rather than “image name”, but lets keep it simple. Make sure you insert the “image name” exactly as it is written in the Task Manager. Spelling counts on this one.

Note to XP Home users: Microsoft, in its infinite wisdom, included the “taskkill.exe” program in XP Pro, but not in XP Home. Not to worry though, because you can download taskkill.exe by Googling it and choosing from a number of download links. I’m not giving a hyperlink here because I already had this program on my machine, and I can’t speak to the safety of any of these sites. Once you have taskkill.exe, place it in you C:\WINDOWS\System32 folder, and you’re good to go. The program is perfectly compatible with XP Home, it just doesn’t come in the box.

Add all of the services that you want to kill to your list, and then you are ready for the next step.

Starting PR
Next, you need to start the game. Use this code to start PR (assuming you have installed it in the default directory).

Start /w "" "C:\Program Files\EA GAMES\Battlefield 2\BF2.exe" BF2.exe +modPath mods/pr +menu 1 +widescreen 1 (etc…)

This is one place where the syntax gets a little tricky. Let’s take it step by step. Obviously, the “Start” command starts the program. The “/w” parameter tells the batch file to wait until this program has terminated before going to the next step. This will keep the batch file from reloading your services until you have quit BF2. The two quote brackets with no text in between them are not typos. XP uses the first set of quotes to determine the title for the command window, and uses the second set to actually execute the command. If you don’t have these empty quotes in your command, then Windows just thinks you are giving it a name with no instructions.

Please also note that you need to add the program name “BF2.exe” after the quoted file path before you get into your extra commands. I don’t know why this is necessary, but the program won’t run unless you do it. Also, all of the BF2 command line options need to be placed outside of the quotation marks.

Restarting You Services
So you play some PR, you own a few fools, and then your wife starts yelling at you to stop playing that *@$!*% game and come help her with dinner. Time to get on with it. Add this code to automatically restart your services and programs once you quit BF2:

Net Start “[Name of service as listed in Services.msc]”

I don’t know why, but I don’t think you can start a service simply by referring back to the executable file. Instead, you have to use the service’s full name listed under on the Services.msc file. Also, if the service name has spaces, you need to place it in quotation marks.

Of course, it can’t be that simple. Just like “Net Stop”, the “Net Start” command only works for services listed under Services.msc. If you want to load up any other programs, you have to use the “Start “” “C:\Program Files\....”” command to direct the batch file to the specific file path. Microsoft, you’re killing me.

Creating a shortcut
According to several sources, you can’t change the icon for a batch file (someone please correct me if I’m wrong). Now I don’t know about you, but I don’t think the icon used for the batch file is very attractive. I like the PR dog tags, and I don’t want replace those with a stupid sprocket. To remedy this, just change your PR shortcut to point to the batch file. You don’t need to put it any of the command line modifiers here, as these are already addressed in the batch file itself.

That’s pretty much it. This is a pretty easy way to reclaim your system resources without reducing your functionality at other times. Like I said, I’m psyched. Happy gaming.

-=x0(GHOST)0x=- is offline
Last edited by -=x0(GHOST)0x=-; 02-21-2008 at 01:12 PM.
Reply With Quote
Old 02-21-2008, 02:50 PM   #2

muddy's Avatar
This worked fine for me, but then AVG started picking it up as a virus and won't let me open it anymore. Any ideas?
muddy is offline Reply With Quote
Old 02-21-2008, 02:58 PM   #3

Deadfast's Avatar
Quote:
Originally Posted by muddy View Post
This worked fine for me, but then AVG started picking it up as a virus and won't let me open it anymore. Any ideas?
Get yourself a better AV.

Nah, seriously, AVG should have some safe files database. Try to add it there.



Turn 360 degrees and walk away is what you should do tbh.
- [R-CON]Desertfox
Deadfast is offline Reply With Quote
Old 02-21-2008, 03:25 PM   #4

-=x0(GHOST)0x=-'s Avatar
Yeah, the safe database was my only idea on how to fix your issue too. I use Avast as my AV software, and the batch file is not picked up as a virus. I don't know which program is better, but I've heard good things about both of them, and they're both free. Sorry I can't give you a better answer. I always hate it when someone's solution is to completely change the way I do things, but I can't really think of anything else at them moment.

-=x0(GHOST)0x=- is offline Reply With Quote
Old 02-22-2008, 02:40 AM   #5
Supporting Member

Sgt_carbonero's Avatar
google fsautostart , way easier and better.
Sgt_carbonero is offline Reply With Quote
Sponsored Links
Old 02-22-2008, 10:20 AM   #6

cannibal23's Avatar
Quote:
Originally Posted by muddy View Post
This worked fine for me, but then AVG started picking it up as a virus and won't let me open it anymore. Any ideas?
look in the avg menu to see if there is a way to set exceptions. most av software have the ability for you to tell it to ignore a file or folder.
cannibal23 is offline Reply With Quote
Old 02-22-2008, 11:42 AM   #7

crAck_sh0t's Avatar
while your on subject on changing tct to bat.

on xp its simple you just type txt

Any idea how to make bat or even CFG files on vista 32?
crAck_sh0t is offline Reply With Quote
Old 02-22-2008, 01:36 PM   #8

-=x0(GHOST)0x=-'s Avatar
Quote:
Originally Posted by crAck_sh0t View Post
while your on subject on changing tct to bat.

on xp its simple you just type txt

Any idea how to make bat or even CFG files on vista 32?
I don't have Vista, so I don't know if this will work. It's worth a shot though. Open up a new ".txt" file, and go to File => Save As. In the file name field, type in the file name and add ".bat" to the end of it. You can leave the "Save as type" field alone, because Windows will automatically convert it to the proper file type based on the extension. This works for XP, and I don't see why it wouldn't also work for Vista.

-=x0(GHOST)0x=- is offline Reply With Quote
Sponsored Links
Reply


Bookmarks

Tags
automatically, free, ram, restart, services, shutdown, systems
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 07:55 AM.


Powered by: vBulletin. ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO.
All Content Copyright ©2004 - 2008, Project Reality.