Recipe 4.2. Creating and Deleting a FolderProblemYou want to create or delete a folder. SolutionUsing a graphical user interface
Using a command-line interfaceTo create a folder, use the mkdir command (or md for short): > mkdir c:\scripts To remove a folder, use the rmdir command (or rd for short): > rmdir c:\scripts Use the /s option to remove a folder and all files and subfolders contained within it. Use the /q option to bypass the confirmation prompt when using /s. To delete a folder on a remote server, use the psexec.exe command: > psexec \\<ServerName> cmd.exe /c rmdir /s c:\temp To provide alternate credentials with psexec, use the /u and /p options to specify a username and password, respectively. Using VBScript' This code deletes a folder ' ------ SCRIPT CONFIGURATION ------ strFolderPath = "<FolderPath>" ' e.g., "d:\temp" ' ------ END CONFIGURATION --------- set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.DeleteFolder(strFolderPath) WScript.Echo "Successfully deleted folder" |