kishkin
kishkin

Reputation: 5325

Location of the temp folder on remote windows

How can I determine 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!

Upvotes: 3

Views: 2959

Answers (2)

Sterex
Sterex

Reputation: 1028

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.

Upvotes: 0

Alex K.
Alex K.

Reputation: 176006

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

Upvotes: 2

Related Questions