Computing.Net > Forums > Disk Operating System > Help!! Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help!! Batch File

Reply to Message Icon

Name: Milton Ezeh
Date: July 15, 2003 at 00:50:40 Pacific
OS: NT
CPU/Ram: 233
Comment:

I need help with writing a batch file that returns an error code to another application (app1).

My batch file is called by another application, when my batch file runs, it calls a VBS Script. This script on completion returns an error code of either 1 or 1 or 2.

My batch file should capture this return code, and return it to the main application (app1)

The problem I have is that my batch file returns an error level 0 to the main application.

This is a snippet of my code
--------------
c:\winnt\system32\cscript.exe d:\ABC.vbs %1

if errorlevel 2 goto errorthree
if errorlevel 1 goto errorone

:errorthree
ECHO.
ECHO DTF file transfer process failure
ECHO.
goto end

:errorone
ECHO.
ECHO DTF file failed to transfer successfully
ECHO.
goto end

:end
---------

If I type in echo %errorlevel%, it returns zero, even when the vbs file returned an error code of 2 or 1.

Any help will be useful.
Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: July 15, 2003 at 22:07:53 Pacific
Reply:

First of all, let's clear something up: the errorlevel is not an environment variable. On NT systems, the environment variable %errorlevel% is automatically set to the errorlevel's value. If you change the value of the environment variable %errorlevel%, the value of errorlevel will not change because of that.

If your VBS script returns a certain errorlevel, it will not be changed unless some other program or command change it. No command on that piece of code you posted can change the errorlevel, not that I'm aware of. However, some other command from another part of the code might be changing it.

Generally, external commands (such as FIND, FC, XCOPY, RENAME) will change the errorlevel. In Windows NT4-, it seems the REM command can also change the errorlevel, but the comment syntax "::comment" won't.

You may save the errorlevel on a variable right after the script, run the rest of commands, which could change the errorlevel, then restate the errorlevel. However, I'm unsure of what method to use to set the errorlevel to a certain value via batch file...

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: Srihari
Date: July 17, 2003 at 23:21:08 Pacific
Reply:

Even Iam facing the same problem.
Iam trying to execute a copy command and checking the error level.

My command is
copy c:\temp\file.txt d:\application >nul 2>error_log

error_log file is created in spite of the succesful operation.

I dont understand that when Y error stream is called and file created.

This error_log file has no data and 0 bytes.

Reagards

Srihari


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Help!! Batch File

HELP!! Batch Files www.computing.net/answers/dos/help-batch-files/13176.html

Help batch file programming www.computing.net/answers/dos/help-batch-file-programming/14554.html

basic batch file help needed www.computing.net/answers/dos/basic-batch-file-help-needed/1019.html