Jump to content

Get drive path of operating system


Recommended Posts

I cannot find a means to identify the path of the OS drive without a degree of sloppiness and in all environments.

So far the only two means I know of are like so:

1.) Works so long as the home path resides on the same drive the OS does. Useless to me in my work environment.

$dir = @HomeDrive
MsgBox(0,"",$dir)

2.) Works for the most part, but really sloppy. Becomes a pain when having to use the path literally in comparisons or when treated as a string for StringCompare() functions since it needs to be sanitized of the workaround addition in the path before use.

$dir = @WindowsDir & '\..'
FileChangeDir($dir)
$dir = @WorkingDir
MsgBox(0,"",$dir)

Of course FileChangeDir() doesn't need to be used. It just produces quick viewable results to describe my problem.

Link to comment
Share on other sites

What if you grab the first three chars with StringLeft?

$sWindowsDir = StringLeft(@WindowsDir, 3)
MsgBox(0, "", $sWindowsDir)

Gives the same result as your script in half the lines :huh2:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...