Page 1 of 1
IF command is true echo smoething
Posted: 10 Dec 2012 07:23
by icikato
Hi can someone help me to work this out
And is is posible to have something like this...
i just need return back of this command like is it done or thera is an Error like synatax or something ...
IF (START "" "C:\Windows\system32\Notepad.exe")=True Echo OK
thanks a lot
Re: IF command is true echo smoething
Posted: 10 Dec 2012 08:37
by Ed Dyreen
Hi icikato
icikato wrote:Hi can someone help me to work this out
And is is posible to have something like this...
i just need return back of this command like is it done or thera is an Error like synatax or something ...
IF (START "" "C:\Windows\system32\Notepad.exe")=True Echo OK
thanks a lot
It doesn't work like that, the if command does STRING compare only, but you can use the '&&' and '||' operators aswell as errorLevel.
Code: Select all
START "" "C:\Windows\system32\Notepad.exe" &&echo.succes ||echo.failed
Code: Select all
START "" "C:\Windows\system32\Notepad.exe"
if not errorLevel 1 (echo.succes)else echo.errorLevel %errorLevel%
Hope it helps,
Re: IF command is true echo smoething
Posted: 10 Dec 2012 10:29
by RogerSmith
Hi why should the file not open?
well if is realy the notepad that you want to open this code is not bullet proof .....
Code: Select all
start notepad.exe
tasklist | findstr "notepad.exe" || if not errorlevel 1 echo OK
if is realy the notpad. the code can be bigger cause the user can be running other notepads, but i was just passing by im in a kind of hurry , let me know if the above code fits to you... or else it have to be different ,like get the notepads pid open the notepad and chek if the new notepad pid is running, if you know how to code it , do it. i got to go. regards