Get Special Directories - Codoid
Select Page
Codoid Blog

Get Special Directories

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

How to get Desktop, MyDocuments, ProgramFiles & Temp directories path at runtime?
This is possible using DotNetFactory and WScript.

DotNetFactory

Function GetDirectoryPath(ByVal strDirName)
Dim oSpecialDir
Set oSpecialDir=DotNetFactory.CreateInstance("Microsoft.VisualBasic.FileIO.SpecialDirectories","Microsoft.VisualBasic")
Execute "GetDirectoryPath=oSpecialDir."&strDirName
Set oSpecialDir=Nothing
End Function

Msgbox GetDirectoryPath("Desktop")
  

WScript

Dim WSHShell:Set WSHShell = CreateObject("WScript.Shell")

Msgbox WSHShell.SpecialFolders("Desktop")
  

Submit a Comment

Your email address will not be published.


How to get Desktop, MyDocuments, ProgramFiles & Temp directories path at runtime?
This is possible using DotNetFactory and WScript.

DotNetFactory

Function GetDirectoryPath(ByVal strDirName)
Dim oSpecialDir
Set oSpecialDir=DotNetFactory.CreateInstance("Microsoft.VisualBasic.FileIO.SpecialDirectories","Microsoft.VisualBasic")
Execute "GetDirectoryPath=oSpecialDir."&strDirName
Set oSpecialDir=Nothing
End Function

Msgbox GetDirectoryPath("Desktop")
  

WScript

Dim WSHShell:Set WSHShell = CreateObject("WScript.Shell")

Msgbox WSHShell.SpecialFolders("Desktop")