Jump to content
Sign in to follow this  
argoran

Reading Recently Set Env Vars

Recommended Posts

argoran

I have created a VBScript to set an environment variable and launch it from an AutoIt Script with ExpandEnvVars = 1 - for some reason the Variable is not read unless I either create the environment variable outside the Autoit script or re-run the autoit script after the env var. has been created it won't be read and I only get back the %Trigram% ... any ideas?

This is the VBScript

Option Explicit

Dim ObjShell, strComputerName, strExpCompName, strTriGram

Set ObjShell = CreateObject("WScript.Shell")

strComputerName = "%COMPUTERNAME%"

strExpCompName = ObjShell.ExpandEnvironmentStrings(strComputerName)

strTriGram = Left(strExpCompName, 3)

ObjShell.Environment.Item("TRIGRAM") = strTriGram

and this is the Autoit Script ( the part that I need anyway ) I have highlited where the Entries are failing -

Opt("ExpandEnvStrings", 1)

Run('D:\Packeteer\ReportCenter\bin\launch.exe -w "D:\Packeteer\ReportCenter" console')

Run('C:\Windows\System32\cscript.exe C:\Windows\logs\ca.vbs')

sleep(10000)

WinWaitActive("Create New Collection Agent","")

Send("%TRIGRAM%PKC001{ENTER}")

WinWait("Modify %TRIGRAM%PKC001","")

If Not WinActive("Modify %TRIGRAM%PKC001","") Then WinActivate("Modify %TRIGRAM%PKC001","")

WinWaitActive("Modify %TRIGRAM%PKC001","")

Send("{TAB}%TRIGRAM%PKC001{ENTER}")

Share this post


Link to post
Share on other sites
Blue_Drache

I believe that when the Au3 is launched it creates something akin to a sandbox of the environment variables. It copies in the pointers where the existing ones reside.

Why not use the Shell("programname.exe") method to launch your script instead of watching for an Environ()?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.