As Glenn implies, using any of the RUNAS type tools will change your environment.

It makes sense when you think about it - if you are running the job as someone else, you would expect to have their environment, as if you had logged on as them.

Try the following to demonstrate the process:
  1. Open a command prompt (Start->Run->CMD)
  2. CD to the root of your C: drive (CD \)
  3. Start a new command prompt using your RUNAS user (RUNAS /USER:domain\user cmd)
  4. Notice that the RUNAS command prompt is in a different directory.
  5. At each of the two command prompt type "SET" to view the environment variables - notice that some are missing and many are different, including TEMP.
  6. (if you have never used regedit then skip this step as you can badly damage the OS and applications by fooling around in the registry) At each prompt start regedit, and take a look at "HKEY_CURRENT_USER" - notice again these are very different

So that demonstrates the problem, now how do you get around it?

Well, the easiest way is to pass the variable on the command line to the child script. For example, in non-Kix2exe scenario you would do this:



Dim $MYLOGFILE


$MYLOGFILE=%TEMP%+"\logfle.txt"


; Pass log file to child script
SHELL '"'+%COMSPEC%+'" /C kix32.exe $$MYLOGFILE="'+$MYLOGFILE+'" childscript.kix"



When "childscript.kix" starts the variable MYLOGFILE will be set. Kix2Exe probably provides a similar mechanism for passing parameters to the script.