MSFN Forum: Batch file help please - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch file help please Rate Topic: -----

#1 User is offline   Batch User 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 23-November 06

Posted 23 November 2006 - 11:48 PM

Does anyone know anything about batch files? I'm trying to make one that will close firefox and then open it again. I can get it to start firefox again, but I've been looking around for a way to close it, but I can't get any of it to work.

All help appreciated!
Thanks!


#2 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 24 November 2006 - 12:42 AM

Try This

Quote

@Echo Off
CLS
start /w taskkill /F /IM PLACE_THE_NAME_OF_APP_HERE
:: Stops The Script For Approx 5 Seconds Then Restart The App
ping -n 5 127.0.0.1>nul
start PLACE_THE_NAME_OF_APP_HERE

This post has been edited by gunsmokingman: 24 November 2006 - 12:42 AM


#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 24 November 2006 - 08:00 AM

Since everyone tends to have cmdow.exe, but rarely uses any of its features, I thought I'd produce an alternative method for you!
@CMDOW @ /HID &FOR /F %%? IN ('CMDOW /T /B ^|FIND /I "FIREFOX"') DO (IF ERRORLEVEL 0 (CMDOW %%? /END &&(PING -n 6 LOCALHOST &CMDOW /RUN FIREFOX)))
This code should all be pasted onto a single line of your batch file.

For those of you not already in posession of the cmdow utility, you can download it directly here and read more here.

#4 User is offline   Batch User 

  • Newbie
  • Group: Members
  • Posts: 28
  • Joined: 23-November 06

Posted 24 November 2006 - 06:47 PM

Hmm... what is the taskkill thing? Is it an exe in system32 or something? I searched my computer for that and it wasn't there, maybe I'm missing it or something...

#5 User is offline   quijibo 

  • Group: Members
  • Posts: 5
  • Joined: 01-October 06

Posted 24 November 2006 - 07:08 PM

Taskkill was implemented in Windows XP. If you're running an older OS, download pskill in it's place. If you drop pskill into your %WINDIR% the code of line three would be:
pskill firefox


If you put pskill in the same directory as the batch file the syntax of line three would be:
.\pskill firefox


I've found pskill to be more powerful than taskkill at killing some apps.

This post has been edited by quijibo: 24 November 2006 - 07:10 PM


#6 User is offline   DJPro 

  • Member
  • PipPip
  • Group: Members
  • Posts: 115
  • Joined: 15-June 05

  Posted 24 November 2006 - 07:09 PM

Taskkill.exe is indeed in system32. Although in WIN XP PRO.
Maybe you have the home edition and there it's called tskill.exe

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy