CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    218

    VBScript to get Windows Directory?

    How do I get the window's directory using VBScript? Here's how I get the Program Files Directory:

    Code:
    Function GetProgramsFolder()
    	Dim wshShell
    	Set wshShell = WScript.CreateObject("WScript.Shell")
    	GetProgramsFolder = wshShell.SpecialFolders("AllUsersPrograms")
    End Function

  2. #2

    Re: VBScript to get Windows Directory?

    Try this:

    Code:
    set shell = WScript.CreateObject("WScript.Shell")
    
    windowsdir = shell.ExpandEnvironmentStrings("%windir%")
    
    MsgBox(windowsdir)

  3. #3
    Join Date
    Aug 2005
    Posts
    218

    Re: VBScript to get Windows Directory?

    How about the system windows directory?

    for example: when you're in a machine with Terminal Services, I want the system windows directory rather than C:\Documents and Settings\Adminstrator\WINDIR

    thanks!
    Last edited by koden; October 31st, 2005 at 06:46 PM.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: VBScript to get Windows Directory?

    %windir% is a constant. How did it load the profile WINDOWS folder?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Aug 2005
    Posts
    218

    Re: VBScript to get Windows Directory?

    anyone know how to get the SYSTEM windows directory? I need this in the case where there are multiple users in a terminal services enabled machine.

  6. #6

    Re: VBScript to get Windows Directory?

    Open a command prompt and type "set" and press enter. This will show you all the current environment variables. Find the one you need and use it accordingly.

  7. #7
    Join Date
    Aug 2005
    Posts
    218

    Re: VBScript to get Windows Directory?

    Quote Originally Posted by mmetzger
    Open a command prompt and type "set" and press enter. This will show you all the current environment variables. Find the one you need and use it accordingly.
    I need to program this dynamically, so that anyone running my vbscript will have their system's windows directory path available.

    please help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured