Exporting an Environment Variable from a CMD line VB exe

  • Thread starter Thread starter Jimmy
  • Start date Start date
J

Jimmy

Hello,
I need to have a VB progam Decrypt a Password, and
Export it Back to the Calling CMD.Exe window as an
Environment Variable that can be used later then the Batch
file. So far, I've tried Setting the Variable in the VB
Code, but it is Destroyed when the code completes. I've
tried using the SETX and SETENV Utilities that Save the
Variable and Value to the Registry (Not what I would
prefer, but I can clean up later), But then the value is
Still not visable to the Current CMD Console Window or any
of it's children. I've Tried using the SendMessageTimeout
Call, but It Doesnt look like CMD.EXE is listening for
that message. Does Anyone Have Any Suggestions ?
 
Jimmy said:
Hello,
I need to have a VB progam Decrypt a Password, and
Export it Back to the Calling CMD.Exe window as an
Environment Variable that can be used later then the Batch
file. So far, I've tried Setting the Variable in the VB
Code, but it is Destroyed when the code completes. I've
tried using the SETX and SETENV Utilities that Save the
Variable and Value to the Registry (Not what I would
prefer, but I can clean up later), But then the value is
Still not visable to the Current CMD Console Window or any
of it's children. I've Tried using the SendMessageTimeout
Call, but It Doesnt look like CMD.EXE is listening for
that message. Does Anyone Have Any Suggestions ?

Thinking back to MS-DOS days, doesn't each process have
its own environment? The 'trick' is to trace back to the master
environment (I could dig out some code) and set the variable
there. As it is you're just setting the variable in the current
process's environment which is destroyed when this process
terminates.
 
Back
Top