Recipe 8.2. Creating and Deleting a Folder


Problem

You want to create or delete a folder.

Solution

Using a graphical user interface

  1. Open Windows Explorer.

  2. In the left pane, browse to the folder where you want to create a folder or that contains the folder you want to delete. Click on the folder.

  3. To create a new folder, right-click in the right pane and select New and the type of folder you want to create.

  4. To delete a folder, right-click the folder in the right pane and select Delete. Click Yes to confirm. This moves the folder and its contents to the recycle bin.

Using a command-line interface

To 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 system, use the psexec command (from Sysinternals):

> psexec \\<ComputerName> 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 downloadable software

If you want a New Folder option when you right-click in the left pane of Windows Explorer, check out the following tool: http://www.createwindow.com/freeware/newfold.htm.

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"



Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net