Re: help needed

Tech-Archive recommends: Speed Up your PC by fixing your registry



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

<gemini.rajesh@xxxxxxxxx> wrote in message news:1153117083.223438.215840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: 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
:


.



Relevant Pages

  • Re: help needed
    ... :> returns an exit code of 0 to the script! ... You are correct that ECHO doesn't change the errorlevel in the batch file, ... :>: get the ERRORLEVEL value from this bat file into an VBScript. ... :>: REN fil fils ...
    (microsoft.public.scripting.vbscript)
  • Re: help needed
    ... :> returns an exit code of 0 to the script! ... AFAIK 'Echo', as most internal dos commands, doesn't change the existing ... 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. ...
    (microsoft.public.scripting.vbscript)
  • Re: Returning a value from a VBScript
    ... VBScript for use by another script, batch file, or other command. ... echo MyScript.vbs returned an ErrorLevel of %ErrorLevel% ...
    (microsoft.public.scripting.vbscript)
  • Re: ERRORLEVEL
    ... the intent was would be the person who wrote the script. ... %errorlevel% appears within a compound statement. ... @echo off ... Echo Connection Failed for to %%c>>Log.txt ...
    (microsoft.public.windows.server.scripting)
  • Re: login script question
    ... Mark-Allen Perry ... if not ErrorLevel 1 set OpSys=Win95 ... echo This machine runs %OpSys% ... > How would you script a login to run something dependent ...
    (microsoft.public.win2000.general)