JSI Tip 10486. How can a Vbscript determine the drive/folder path of the script?

In a batch script, you can determine the the folder path of your script by using the %~DP0 parameter.

To determine the folder path of a Vbscript, use:

sn = Wscript.ScriptName '        Script Name        
fn = Wscript.ScriptFullName '    Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path

Wscript.Echo fp

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.