View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ChristopherL ChristopherL is offline
external usenet poster
 
Posts: 18
Default How do I set an environment variable to a string

On Aug 13, 7:31*am, Dave Peterson wrote:
The environment variable would be alive as long as the Shell is alive--but it's
limited to that shell and its children.

So if you need to run a .bat file that needs an environment variable, you could
shell to a different .bat file that sets the environment variable and then runs
the .bat file that you need to run.

But if you want to change the environment variable globally, it's a different
story. *

Win95 came with command called WinSet that did this. *But I don't see it in
WinXP (at least in a normal install).

But you could search google looking for alternatives.

I've never used this, but it looks interesting:http://www.codeguru.com/cpp/w-p/win3...le.php/c10849/

....

Dave Peterson- Hide quoted text -

- Show quoted text -


Dave, I tried the following, but in the command prompt window it
said:

'%chris%' is not recognized as an internal or external
command, operable program or batch file.
Chris

Sub test6()

Dim count As Long
Dim ev_result As String

Row = 30

count = 0

ev_result = Wait_("cmd /k set chris=""1 2 3"" & %chris%", "", False,
True)
ev_result = Environ("chris")

Debug.Print "--- " & ev_result & " <---"

Debug.Print "end"
End Sub