VBScript - accessing special folders remotely

Posted on 2004-11-04
Last Modified: 2006-11-17
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.


Question by:dcx45
    LVL 70

    Accepted Solution


    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

    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 ;)

    Author Comment

    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.
    LVL 70

    Expert Comment

    by:Chris Dent

    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 ;)

    Author Comment

    No  that's cool, points on their way

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
    On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now