1.

Solve : Check if a program exists?

Answer»

Does anyone know how to check if a progress exists witch DOS? I'd like to do the following
if a certain progress doesn't exist, then call a batch file that creates it.

Can anyone help me with the command if a progress exists and an if-not-statement?

I run winxp btw, and I have googled yet but I didn't find anything usefullFirstly, I assume you don't mean DOS, you mean a Batch file that the command line will interpret COMMANDS from.

Secondly, Is there a difference between a program and a progress? How is the program installed? Is it just one file or a directory? How would it be created from just a batch file??

Yes it can be done but you haven't given us much to go on.

Quote


@echo off
set check=file/directory to check exist

if exist "%check%" (goto end) else (
:: Create a file here
>"%check%" echo Make file?
)

:end
echo File exists
pause >nul
exit
Quote from: DeltaSlaya on August 22, 2007, 04:03:55 AM
Firstly, I assume you don't mean DOS, you mean a Batch file that the command line will interpret commands from.

Secondly, Is there a difference between a program and a progress? How is the program installed? Is it just one file or a directory? How would it be created from just a batch file??

Yes it can be done but you haven't given us much to go on.

I mean a batch file, correct.
The programm is installed like a normal program with a lot of files and directories. Afcourse there is a difference between a program and a progress. You have for instance notepad, and you can only check if notepad is LAUNCHED if the process notepad.exe exists. The progress itself wouldn't be created by the batch file, it would just LAUNCH the programm by doing "c:/program.exe".

Thanks for your help so far

OH I see, you mean process...

Yea that's easy ENOUGH:

Quote

@echo off
tasklist | findstr /I /c:"program.exe" || (start "" "program to start" & goto end)
echo Program was running
pause >nul
exit

:end
echo Program Started
pause >nul
exit
How do you get a lists of taskes 'cause tasklist doesn't work here..
Thanks so far for your helpTasklist doesn't do anything at all?

What OS?Quote from: DeltaSlaya on August 22, 2007, 04:22:31 PM
Tasklist doesn't do anything at all?

What OS?

winxp homeAre you sure tasklist doesn't do anything? It should, shouldn't it ? ?

Try the CODE again and tell me the exact output.tasklist doesn't come with XP home. you can download from this site. Here .
you can also use pslist and pskill . Otherwise
here's a vbscript.
Code: [Select]status = 0
Set Processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery("select * from Win32_Process")
For each Process in Processes
If Process.Description = "the_process_you_want_to_check.exe" Then
status=1
End If
Next
If status = 0 Then
Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec("program_2")
End If


Discussion

No Comment Found