Get the exit value of batch file using vbscript -
please lend help, i'm beginner batch file , vbscript. grateful if me solve problem.
given:
a:
@echo off pushd "c:\program files\appname" && popd if errorlevel 1 exit 0 pushd "c:\program files\appname" if exist application.exe goto installed popd exit 1 :installed exit 2
b:
set objfso = createobject("scripting.filesystemobject") 'set objfile = objfso.opentextfile(listfile, 1) dim sh , res objname = objfso.gettempname objtempfile = objname '---- sample code 0 ----------------------' 'set sh = wscript.createobject("wscript.shell") 'res = sh.run("filefullpath",0,true) 'wscript.echo res '----sample code 1 ---------------' 'set sh = wscript.createobject("wscript.shell") 'res = sh.run("filename",0,true) 'wscript.echo res '---- sample code 2 --------------------- 'set sh = wscript.createobject("wscript.shell") 'res = sh.run("cmd /c filename",0,true) 'wscript.echo res '---- sample code 3 --------------------- 'set sh = wscript.createobject("wscript.shell") 'res = sh.run("cmd /c filefullpath",0,true) 'wscript.echo res
the b:sample code 1 & 2 works fine me need sample code 0 & 3. sample code 1 error : system cannot find file selected ,while sample code 3 return 0 when failed 1 when successful, , not returned value of batch file.
thanks,
i got problem solved while ago. found out even-though have had "cmd /c filefullpath"
double-quoted. when folder name(s) consists spaces, cause issue --> file can't found. i'm using "cmd /c ""filefullpath"""
instead.
sorry having first post lack of information. best make clearer next time. lot. :d
Comments
Post a Comment