Re: help needed by Walter
Walter
Mon Jul 17 09:05:06 CDT 2006
"Alexander Mueller" <millerax@hotmail.com> wrote in message
news:uWxgKrYqGHA.3732@TK2MSFTNGP04.phx.gbl...
: Walter Zackery schrieb:
: > Your very last statement "echo %ERRORLEVEL%" runs successfully, so it
: > returns an exit code of 0 to the script! If you remove this statement it
: > will solve your problem.
:
:
: AFAIK 'Echo', as most internal dos commands, doesn't change the existing
: errorlevel. The prob is the most likely that the COMSPEC (cmd.exe) needs
: to be switched in between to get to exitcode returned.
:
: i = wShell.Run ("%comspec% /c C:\test1.bat", 1, True)
:
: MfG,
: Alex
:
You are correct that ECHO doesn't change the errorlevel in the batch file,
but I can tell you from repeated testing that it does make a difference in
what is returned to the Run method. It also makes no difference whether you
invoke the command processor or not., the result is the same. It's very
peculiar behavior.
: > <gemini.rajesh@gmail.com> wrote in message
: > news:1153117083.223438.215840@s13g2000cwa.googlegroups.com...
: > : Im writing an bat file to rename an file with a new name, and i need
to
: > : get the ERRORLEVEL value from this bat file into an VBScript.
: > : I m always getting an zero errorlevel when i run the bat file from the
: > : script
: > : My code is below...
: > :
: > : BAT FILE
: > : ---------------------------------
: > : @echo off
: > ::: do something that sets errorlevel 1
: > : REN fil fils
: > : echo %ERRORLEVEL%
: > : (this would return an 1 when run from dos prompt)
: > :
: > : VBScript
: > : -------------------------------------
: > : Dim fso, wShell, i
: > : Set wShell = CreateObject("WScript.Shell")
: > : Set fso = CreateObject("Scripting.FileSystemObject")
: > : i = wShell.Run ("C:\test1.bat", 1, True)
: > : WScript.Echo i
: > : (This should return 1, but returns only 0)
: > :
: > : Y is this happening, is there anything wrong with my logic
: > :
: > : Rajesh.N
: > :
: >
: >