Search code examples
vbscriptdirectorybasic

How to create a directory in Scripter Automation


Is it possible to create a directory in Scripter Automation? If so, how?

I need to call ActiveX plugin. In VB you can call it with

My.Computer.FileSystem.CreateDirectory("C:\Documents and Settings\AllUsers
\Documents\NewDirectory")

Solution

  • You need to create a FSO and use its .CreateFolder method:

    >> Set oFS = CreateObject("Scripting.FileSystemObject")
    >> s = "NewDirectory"
    >> WScript.Echo CStr(oFS.FolderExists(s))
    >> oFS.CreateFolder s
    >> WScript.Echo CStr(oFS.FolderExists(s))
    >>
    Falsch
    Wahr