Results 1 to 3 of 3

Thread: How to make use of VB Script to get Current Directory?

  1. #1
    Join Date
    Jan 2009
    Posts
    96

    How to make use of VB Script to get Current Directory?

    Hello,

    How can i use VBScript to get the current directory? so if i run test.vbs in C:\data

    I want to figure out that I am running in C:\data from test.vbs.

    Any ideas?

    Thanks

  2. #2
    Join Date
    Mar 2008
    Posts
    232

    Re: How to make use of VB Script to get Current Directory?

    here you will get some useful script that would get the current directory your script is running from. This is great for referencing other files.

    http://leereid.wordpress.com/2008/03...ory-or-folder/

    Pretty simple one to follow, it grabs the script name (with path), finds the length, grabs the script name by itself, finds the length, subtracts and you’re left with the path. Too easy, but really useful.

    Very good, however this is more simpler:

    Set oShell = CreateObject(”WScript.Shell”)
    Set ofso = CreateObject(”Scripting.FileSystemObject”)
    oShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)

  3. #3
    Join Date
    Mar 2008
    Posts
    227

    Re: How to make use of VB Script to get Current Directory?

    Hi,
    Do this:

    Dim sCurPath
    CurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")


    I hope this solve your problem.

Similar Threads

  1. Replies: 4
    Last Post: 20-10-2010, 11:56 AM
  2. Get latest updated file from your Current Working Directory
    By REDBULL in forum Software Development
    Replies: 4
    Last Post: 10-07-2010, 02:38 PM
  3. Batch script to delete directory
    By Logan 2 in forum Software Development
    Replies: 4
    Last Post: 01-04-2010, 12:31 PM
  4. Retrieving the current directory in batch
    By Jacques25 in forum Software Development
    Replies: 3
    Last Post: 15-07-2009, 11:36 PM
  5. How to get current directory
    By Scott2580 in forum Software Development
    Replies: 3
    Last Post: 11-10-2008, 03:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,097,674.05704 seconds with 16 queries