IF command is true echo smoething

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
icikato
Posts: 1
Joined: 10 Dec 2012 07:10

IF command is true echo smoething

#1 Post by icikato » 10 Dec 2012 07:23

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 :)

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: IF command is true echo smoething

#2 Post by Ed Dyreen » 10 Dec 2012 08:37

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,

RogerSmith
Posts: 22
Joined: 20 Nov 2012 12:42

Re: IF command is true echo smoething

#3 Post by RogerSmith » 10 Dec 2012 10:29

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

Post Reply