Articles

Batch-- do not start if running

October 13, 2006 at 19:39:42
Specs: XP Home, 2GH/256

Hi,

I have a batch script (below) that I put in the task scheduler to make sure FrostWire file sharing starts again when my Mom turns it off.

I need to know how to tell it to look and see if FrostWire is already running, and if it is, then don't try to run it again. Something like:

if %frostwire%==yes goto exit

(I found that here: http://aroundcny.com/Technofile/tex... )

What should I do?

Thanks much,

Martin

Here's the script so far:

min
"C:\Program Files\FrostWire\frostwire.exe"
sleep 10
window.exe /MIN "FrostWire: Enabling Open Information Sharing"


See More: Batch-- do not start if running

Report •


#1
October 14, 2006 at 05:03:23

Hi Martin,

I don't mean to rain on your parade, but nothing in that batch looks familiar.

But it's worse than that. The WINSET used on that page is [AFAIK] a DOS app and probably won't effect the "global environment". Some things which try to mess with NT will generate a error like "blabla has attempted..." others will simply be ignored.



=====================================
If at first you don't succeed, you're about average.

M2



Report •

#2
October 14, 2006 at 09:32:21

You can do it with a third-party command line process explorer. Then your script would run the command with whatever switch is needed to print the current running processes. Then pipe that through findstr "frostwire.exe".

Here's a sample script:

@echo off
process | findstr "frostwire.exe"
if errorlevel 1 (
goto start) else (
goto :eof
)

:start
start %programfiles%\frostwire\frostwire.exe

I think you'll get the idea.

"Computer security." — Oxymoron


Report •

#3
October 14, 2006 at 20:26:11

How cool, tonysathre,

I have a working script that does exactly what I want. I had to go download process.exe.

Thanks for your help (:

Here's the script for anyone else:

::MINIMIZE THE COMMAND WINDOW...
MIN
::FOR THE findstr, LETTER CASE SEEMS TO BE IMPORTANT. JAVAW.EXE IS FROSTWIRE
process.exe | findstr /C:JAVAW.EXE
if errorlevel 1 (
goto start) else (
goto eof
)
endif
::NOT SURE IF endif MEANS ANYTHING
:start
::THESE MAKE SURE FROSTWIRE MINIMIZES AFTER STARTING, AS FAST AS POSSIBLE, NO MATTER HOW LONG IT HAPPENS TO TAKE TO START
"C:\Program Files\FrostWire\frostwire.exe"
sleep 3
window.exe /MIN "FrostWire: Enabling Open Information Sharing"
sleep 5
window.exe /MIN "FrostWire: Enabling Open Information Sharing"
sleep 8
window.exe /MIN "FrostWire: Enabling Open Information Sharing"
sleep 10
window.exe /MIN "FrostWire: Enabling Open Information Sharing"

:eof


Report •

Related Solutions


Ask Question