View Single Post
  #3  
Old January 24th 05, 04:06 PM
Tobias Goller
external usenet poster
 
Posts: n/a
Default

Greetings,

I guess my problem is a bit more tedious.
To make things short i need to set an env variable to the output of a batch
or command file

Ie.: set MYVAR = mybatch.bat

Is this possible in Win98?

Thank You




"Mikhail Zhilin" wrote in message
...
Is the command, that creates a variable, a batch file, too?
If yes -- you have to run it in the same Command.com process: the parent
process (which calls your second batch) does not inherit the variables
of the child (second batch) process, if the child process is launching
via CALL statement, i.e. in the other Command.com process.

So it can be something like:

::---Main batch (main.bat) begin--
if not "%RETCODE%"="" goto CONTIN
more initial codes here
child.bat
:CONTIN
set RETCODE=
the returned X variable is using here, something like:
if "%X%"="2" then echo "Monday"
more codes here

::---Main batch (main.bat) end--

::---Child batch (child.bat) begin--
more codes here, something like:
echo.|date|find /i "Mon"
if not errorlevel 1 SET X=2
more codes here
SET RETCODE=1
MAIN.BAT

::---Child batch (child.bat) end--

Non-empty RETCODE variable says to MAIN.BAT, that it is the return from
CHILD.BAT -- but not the initial run of MAIN.BAT.
--
Mikhail Zhilin
http://www.aha.ru/~mwz
Sorry, no technical support by e-mail.
Please reply to the newsgroups only.
======
On Mon, 10 Jan 2005 14:18:52 +0100, "Tobias Goller"
wrote:

Hello to everybody!

How can I put a command result in a variable?

For example:

set x={output of the command hostname}

Does sombody know how to do this on win98?


Bye
Tobias Goller