Solved

VBS: finding the root drive.

Posted on 2004-04-13
3
304 Views
Last Modified: 2010-05-18
Hi,

I am putting together a pendrive with all my PuTTY settings and keys etc, there are 3 questions in this topic that should all be easy.

I know I can use VBS to create a shortcut, but I have a problem. When I plug the drive in, I do not know what the root letter will be (D:, E:, F: etc) and so cannot hard code a shortcut. I want to find the drive letter that the VBS script is running from. (Or better, and probably easier yet, the full path in case we are on a junction) is there an easy function to do this?

Thanks
Nigel.
0
Comment
Question by:nigel5
3 Comments
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 10820469
Try this:

GetPath.vbs:

function ShowAbsolutePath(path)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")  
   ShowAbsolutePath = fso.GetAbsolutePathName(path)  
end function

function getDrive(path)
      pos = instr(path,"\")
      if pos > 0 then
            getDrive = left(path, pos)
      else
            getDrive = ""
      end if
end function

msgbox ShowAbsolutePath(".")
msgbox getDrive(ShowAbsolutePath("."))

Hope this helps
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10821640
Or just the below to get the path of the current script.

MsgBox WScript.ScriptFullName
0
 

Author Comment

by:nigel5
ID: 10821790
Ryancys

Thanks, I knew there was a simple solution :)

Cheers
N.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

680 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