Create a folder on a remote server using VBScript
Posted on 2004-04-05
I need to create a folder on a remote server using the FSO in VBScript.
There is a trusted connection between the two servers, however I am running the code on server a, and need it to create the folder on server b before moving to the next step in my process.
I've experimented with the following code:
Sub MakePathRemote(strDirectory, pbHeader)
Set objFSORemote = WScript.CreateObject("Scripting.FileSystemObject")
If pbHeader Then
WriteToOutFile "Creating Folder on remote server " & strDirectory, True, False
intLen = 4
If Right(strDirectory, 1) <> "\" Then strDirectory = strDirectory + "\"
Do While objFSORemote.FolderExists(strDirectory) = False
intDirLen = InStr(intLen, strDirectory, "\")
If objFSORemote.FolderExists(Left(strDirectory, intDirLen)) = False Then
objFSORemote.CreateFolder Left(strDirectory, intDirLen - 1)
intLen = intDirLen + 1
with the value of strDirectory set as '\\<serverb>\folder' but had no luck. The script runs successfully, but doesn't seem to have created the folder anywhere (not even locally)!