Location of the temp folder on remote windows
How can I de开发者_如何学运维termine location of the temp folder on remote Windows machine?
I am able to connect to it using
objSWbemLocator.ConnectServer(strComputer, _
"root\cimv2", _
strUser, _
strPass)
Thanks in advance!
Bearing in mind every local or domain user can have their own path, you can query the Win32_Environment
class:
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemLocator = objSWbemLocator.ConnectServer(strComputer, _
"root\CIMV2", _
strUser, _
strPass)
Set colItems =objSWbemLocator.ExecQuery("SELECT * FROM Win32_Environment WHERE Name='TEMP' AND SystemVariable=FALSE AND username='machine_or_domain_name\\user_whos_temp_path_you_require'", "WQL", 48)
For Each objItem In colItems
msgbox objItem.VariableValue
Next
I'm not very sure but have you tried using the "%TEMP%" variable as the remote folder string? I think windows automatically expands it to the configured temporary folder on the machine.
精彩评论