Solved

VBS: finding the root drive.

Posted on 2004-04-13
3
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 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