Check if folder is there, if not create it on current user logged in VBS

后端 未结 2 1847
孤街浪徒
孤街浪徒 2021-02-13 12:15

Currently this is my script

Set oWS = WScript.CreateObject(\"WScript.Shell\")
\' Get the %userprofile% in a variable, or else it won\'t be recognized
userProfile         


        
2条回答
  •  悲&欢浪女
    2021-02-13 12:35

    Here is code part from my utilty for FSO:

    dim ffso
    
    Function GetFSO
        if not IsValidObject(ffso) then set ffso = CreateObject("Scripting.FileSystemObject")
      Set GetFSO = ffso
    End Function
    
    sub SureDirectoryExists(ADir)
        if ADir="" then exit sub
        if not GetFSO().FolderExists(ADir) then
            SureDirectoryExists ffso.GetParentFolderName(ADir)
            ffso.CreateFolder ADir
        end if
    end sub
    

提交回复
热议问题