Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBS: finding the root drive.

Posted on 2004-04-13
3
Medium Priority
?
328 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 53

Accepted Solution

by:
Ryan Chong earned 400 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

721 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