MOTOBIT.COM - ASP upload, IIS utility Set TEMP and TMP Environment variables

Sample for RegEdit.Key.ExistsKey | Changes | Purchase | Download


Set TEMP and TMP Environment variables 
  Option Explicit
  Dim S, Key, SubKey

  Dim TempFolder 

  If Wscript.Arguments.Count = 0 Then 
    Wscript.Echo "SetTemp - same temp folder for all users on this computer" & vbCrLf & _
     " cscript settemp.vbs tempfolder" & vbCrLf 
  End If

  'Read the temp folder argument
  TempFolder = Wscript.Arguments(0)

  'Get RegEdit.Server object
  Set S = CreateObject("RegEdit.Server")
  'Get a key
  Set Key = S.GetKey("HKU")

  For Each SubKey In Key.SubKeys
    Wscript.Echo SubKey.Name
    If SubKey.ExistsKey("Environment") Then
      Wscript.Echo SubKey.SubKeys("Environment").Values("TEMP")
      Wscript.Echo SubKey.SubKeys("Environment").Values("TMP")

      'Set TEMP and TMP registry Environment variables
      SubKey.SubKeys("Environment").Values("TEMP") = TempFolder
      SubKey.SubKeys("Environment").Values("TMP") = TempFolder
    End If                                                


  'Set system temp  
  Wscript.Echo S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TEMP")
  Wscript.Echo S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TMP")

  S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TEMP") = TempFolder 
  S.GetKey("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment").Values("TMP") = TempFolder

Other links for the Set TEMP and TMP Environment variables sample


One registry key.


Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.

© 1996 - 2009 Antonin Foller, Motobit Software | About, Contacts | e-mail: