• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

VBScript - accessing special folders remotely

Hi Everyone,

WshShell object exposes the Special Folders Collectio.

I need to access this colletction on a remote server - in particular I need to access %SystemRoot%

Any suggestions are welcome.

Hardcoding anything is no-go.

Thanks

0
dcx45
Asked:
dcx45
  • 2
  • 2
1 Solution
 
Chris DentPowerShell DeveloperCommented:

It depends what you want to do with it to be honest, since you mention remotely this is the WMI Method to grab the installation folder:

' The . is for the local computer, change that to the computer name for a remote one.
' This value could be requested (Input Box), or read from a file.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

For Each objItem in colItems
    strSystemRoot = objItem.WindowsDirectory
Next

That returns the full path, including the drive letter. Of course that isn't really a valid network path, so you would need to alter it to make it any use from a remote computer. I'll add that section too if this is heading along the right lines.

Just post again if it is or isn't ;)
0
 
dcx45Author Commented:
Yeah I think it kind of gets me going - this returns the path so I'll be able to make UNC out of it and access a log file in the debug folder, which is what I need.
0
 
Chris DentPowerShell DeveloperCommented:

Brilliant, let me know if you need anything more on it. It's just a matter of breaking down the string to make the UNC, but you probably know that ;)
0
 
dcx45Author Commented:
No  that's cool, points on their way
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now