Can I create a batch file that will execute and termanate certian apps/services?

BurntToast

2[H]4U
Joined
Jun 14, 2003
Messages
3,677
I would like to create batch files and use them like profiles.

Example, when I want to watch a DVD on my computer I would like there to be a way to shut down my ICQ, Gaim, Skype, Hamatachi, X-Fire, Gmail Notifier and god knows what ever applications that will bug me while I'm watching a movie.

Then when the movies over, I would like to create a batch file that will reopen the apps that I closed before watching the movie.

So is there any way to do this and to leave a couple batch files on my desktop for when I would like to perform these options?

Thanks!
 
I assume you know how to make an application start in a batch file. Here's a simple batch file that runs Excel:

****************
@ echo off
Excel.exe
****************

To terminate running applications and/or services, Google for "Taskkill" "Net start:, and "Net stop" commands. Here's a simple batch file that kills Excel if it is running:

****************
@ echo off
taskkill /im Excel.exe
****************

You may need to use full path names depending on the applications and/or services (depending on which folder you run the batch file from or depending on where the applications and/or services you are starting/stopping are located).
 
I can get a few programs to work, but not all. I only seem to beable to get the applications to start when I dont use a full path. But then agian not all aplications will start.

Code:
@ echo off
START gaim
START icq
START Skype.exe
START Xfire
START hamachi.exe
START gnotify.exe

When I do that spkye, hamachi and gnotify wont load.

Code:
@ echo off
START gaim
START icq
START "C:\Program Files\Skype\Phone\Skype.exe"
START Xfire
START "C:\Program Files\Hamachi\hamachi.exe"
START "C:\Program Files\Google\Gmail Notifier\gnotify.exe"

Now when I do this, I still run into the same problems.

So how would I babke to run commands using full path names?

Thanks!
 
Yes, but unless you are memory bound it's not likely to help with performance. So I'd question why you are doing this in the first place. There are some scenarios which it makes a difference, but not many.

Outside that, the net stop and taskkill in a batch file is the way to go. As for your other Qs about pathing, that's odd. Does the same thing happen with the run line?
 
I haven’t tried to kill a task yet. I an interested in getting them to run first :p

For the tasks that fail to run, when the line is executed all I get is a command prompt window that pops up for every failed task.

I have even tried this same batch file in Win2K and get the same results.
 
Phoenix86 said:
Yes, but unless you are memory bound it's not likely to help with performance. So I'd question why you are doing this in the first place. There are some scenarios which it makes a difference, but not many.

Outside that, the net stop and taskkill in a batch file is the way to go. As for your other Qs about pathing, that's odd. Does the same thing happen with the run line?

He said he wants to do it because those apps would "annoy" him while watching a DVD "Oh crap someone IM'ed me.... " yada yada... :)

BurntToast said:
shut down my ICQ, Gaim, Skype, Hamatachi, X-Fire, Gmail Notifier and god knows what ever applications that will bug me while I'm watching a movie.
 
Grimmda said:
He said he wants to do it because those apps would "annoy" him while watching a DVD "Oh crap someone IM'ed me.... " yada yada... :)
You know, I gotta pay more attention. :eek:

What the hell good is taking time off work when your sick only to come back to 2x the workload?
 
I believe your problem is with the "START" command. Try omitting it:

@ echo off
gaim
icq
"C:\Program Files\Skype\Phone\Skype.exe"
Xfire
"C:\Program Files\Hamachi\hamachi.exe"
"C:\Program Files\Google\Gmail Notifier\gnotify.exe"
 
Frank4d said:
I believe your problem is with the "START" command. Try omitting it:

@ echo off
gaim
icq
"C:\Program Files\Skype\Phone\Skype.exe"
Xfire
"C:\Program Files\Hamachi\hamachi.exe"
"C:\Program Files\Google\Gmail Notifier\gnotify.exe"
Hey that works!

But it looks as if the batch file wont move to the next task until the first one is completed.

Example task #1 will always open. But task #2 won’t open until I close task #1 and so on. And until the last task is closed I have a blank/empty command window open in the background performing these tasks.

So how would I open all tasks with just one click w/o having to close down the pervious application?

Thanks!
 
Okay I found out the problem! After doing some hunting I found out that in XP/2K batch files are different than they where in Win9x. You need to run programs not from the executable, but from the shortcuts! Examples...

Code:
@ echo off
"C:\Documents and Settings\User327\Start Menu\Programs\CCleaner\CCleaner.lnk"
"C:\Documents and Settings\User327\Start Menu\Programs\WinRAR\WinRAR.lnk"

This works perfectly!

Thanks for your help :p
 
I created the following batch file to run before I game... feel free to use/modify it as you see fit.



@Echo off

:: Stops services
for %%a in ( schedule "Automatic Updates" "Print Spooler" "Acronis Scheduler2 Service" WinVNC ) do net stop %%a

:: Kills Processes
"D:\Program Files\Applications\Caller ID\QuitCallerID.exe"

for %%a in ( hotsync konfabulator ) do taskkill /f /im %%a.exe /t

:: Starts applications
start "Speedpad" "C:\Program Files\Belkin\Nostromo\nost_LM.exe"
start "XFire" "D:\Program Files\Internet\Xfire\Xfire.exe"
if exist "D:\Program Files\Applications\LogiGamer\LogiGamerLite.exe" start "LogiGamer LITE Auto-Apply" "D:\Program Files\Applications\LogiGamer\LogiGamerLite.exe" /a

cls
color 4F
echo.
echo.
echo ****************************************************
echo Hit any key twice to resume "regular" system status.
echo ****************************************************
echo.

pause
pause

:: Starts services
for %%a in ( schedule "Automatic Updates" "Print Spooler" "Acronis Scheduler2 Service" WinVNC ) do net start %%a

:: Kills gaming-related processes
for %%a in ( nost_LM eye xfire steam LogiGamerLite ) do taskkill /f /im %%a.exe /t

:: Starts Applications
start "Hotsync" "D:\Program Files\Applications\Palm\HOTSYNC.EXE"
start "CallerID" "d:\program Files\applications\caller Id\callerid.exe"
start "Konfabulator" "D:\Program Files\Applications\Konfabulator\Konfabulator.exe"

cls
color 1F
echo.
echo.
echo System back to normal.
echo.

pause

 
get rid of the "START" command. you don't need that shit. Thats most likely why pointing to the executables is failing. See if adding & at the end will make it continue. It might not though, because thats a command grabbed from bash.
 
Whatsisname said:
get rid of the "START" command. you don't need that shit. Thats most likely why pointing to the executables is failing. See if adding & at the end will make it continue. It might not though, because thats a command grabbed from bash.
Yeah I got that now. But I'm still having issues with stopping the service/application.
 
taskkill /f /im gaim.exe /t works perfectly fine for gaim on my box...

Adding START is necessary if you're executing applications from the command line and you want them to detach themselves from the current command prompt so that additional applications may execute. The batch I listed above works beautifully for me without issue. The key to START is giving each each command a "Title" before the actual executable itself.

Adding an & at the end of a command line does not function under the Windows command interpreter as it does under bash...
 
Back
Top