Environment Variables 
Author Message
 Environment Variables

I have to run an old DOS program from my application. How can I change/set
up Environment Variables like in the old .bat: "SET TEMP=C:\TEMP"?

Thank you



Fri, 03 Sep 2004 12:40:04 GMT  
 Environment Variables
Heres how to do it with the WinAPI, I am not sure if VB.net has an inherent
way or not,

Option Explicit

Public Declare Function SetEnvironmentVariable Lib "kernel32" Alias
"SetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String)
As Long
Public Declare Function GetEnvironmentVariable Lib "kernel32" Alias
"GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String,
ByVal nSize As Long) As Long

Public Function Environ(sEnvVar As String) As String
   Dim lpszOrigEnv As Long ''' pointer To environment String
   Dim lpszEnv As Long ''' pointer To copied environment String
   Dim szDOSEnv As String ''' buffer To hold environment string

   szDOSEnv = Space(256)
   lpszEnv = GetEnvironmentVariable(sEnvVar, szDOSEnv, Len(szDOSEnv))
   Environ = Left(szDOSEnv, lpszEnv)
End Function

Public Function SetEnviron(sEnvVarName As String, sEnvVarVal As String) As
Long
   SetEnviron = SetEnvironmentVariable(sEnvVarName, sEnvVarVal)
End Function

Public Function Dele{*filter*}viron(sEnvVarName As String) As Long
   Dele{*filter*}viron = SetEnviron(sEnvVarName, vbNullString)
End Function

BIGDOG



Quote:
> I have to run an old DOS program from my application. How can I change/set
> up Environment Variables like in the old .bat: "SET TEMP=C:\TEMP"?

> Thank you



Fri, 03 Sep 2004 21:08:22 GMT  
 Environment Variables
See Environment.GetEnvironmentVariable to get one -- I don't see a
.NET solution to setting one, unfortunately. -- Ken

On Sun, 17 Mar 2002 23:40:04 -0500, "Manuel De Leon"

Quote:

>I have to run an old DOS program from my application. How can I change/set
>up Environment Variables like in the old .bat: "SET TEMP=C:\TEMP"?

>Thank you



Sat, 04 Sep 2004 07:58:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Environment variable...

2. Write Environment Variables

3. Environment Variables

4. Environment Variables

5. querying environment variables from vba

6. WORD Environment Variables

7. Using Environment Variable in Template path

8. environment variables

9. Extracting environment variables

10. how to set an environment variable?

11. Creating and environment variable and using it in the same cmd window

12. Getting Environment Variables

 

 
Powered by phpBB® Forum Software