Hi guys,

my target is to set a local variable usually done with the set command within a batch file using a vbs script.

I created a vbs script who creates a registry key in HKCU\Environment.

I call the vbs within the batch file (simply the name no call or start or cmd) but from that point on I can not see the
either the variable or its value. I check whether the script works or not putting a set command after calling the vbs
script. There is no trace of the variable just create with the vbs script.

Something like this:

test.vbs
DOS_VAR = "MIA_ter"
set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.RegWrite "HKEY_CURRENT_USER\Environment\"&DOS_VAR, "03"


prova.bat
test.vbs
set
pause


Any hint, please?

I need to work this way, because I've got an old DOS batch file but some variables must be set accordingly on who is
currently logged on my Windows machine.

TIA,

Alex.

Re: Interaction vbs and batch scripts. by Tom

Tom
Mon Jul 17 12:34:29 CDT 2006

Changing the registry entry will not affect the current console's
environment. The only way to affect the current console session's
environment that I have found is to do something like this ...

test.vbs
A_VAR = "MIA_ter"
wsh.echo A_VAR

prova.bat
for /f "delims=" %%a in ('cscript.exe //nologo test.vbs') do set
DOS_VAR=%%a
set DOS_VAR
pause

Further, needing to know the user should not require the VBScript in
the first place, if your target OS is a WinNT variant (WinNT/2K/XP/2003
Server), as the USERNAME variable is provided for that purpose in the
console session.

Tom Lavedas
============
http://members.cox.net/tglbatch/wsh

AM wrote:
> Hi guys,
>
> my target is to set a local variable usually done with the set command within a batch file using a vbs script.
>
> I created a vbs script who creates a registry key in HKCU\Environment.
>
> I call the vbs within the batch file (simply the name no call or start or cmd) but from that point on I can not see the
> either the variable or its value. I check whether the script works or not putting a set command after calling the vbs
> script. There is no trace of the variable just create with the vbs script.
>
> Something like this:
>
> test.vbs
> DOS_VAR = "MIA_ter"
> set WSHShell = WScript.CreateObject("WScript.Shell")
> WSHShell.RegWrite "HKEY_CURRENT_USER\Environment\"&DOS_VAR, "03"
>
>
> prova.bat
> test.vbs
> set
> pause
>
>
> Any hint, please?
>
> I need to work this way, because I've got an old DOS batch file but some variables must be set accordingly on who is
> currently logged on my Windows machine.
>
> TIA,
>
> Alex.