Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VB Script does not change the value of the Environment variable TEMP

$
0
0

On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array("SUNDAR-PC") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "==========================================" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Environment where name = 'temp'", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems WScript.Echo "Name: " & objItem.Name WScript.Echo "VariableValue: " & objItem.VariableValue strCurrentvalue = objItem.VariableValue WScript.Echo ""& strCurrentvalue objItem.VariableValue = "D:\Temp" WScript.Echo ""& objItem.VariableValue Next Next Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function

Hi Scripting Guys,

I am using the above script to change the value of environment variable TEMP to "D:\Temp.

When I run this script it shows the output "D:\Temp" but in the computer environment variable does not change. 

Please give the solution and why it is not changing the value.

Thanks in advance.

Sundar


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>