A personal repository of technical notes. - CSC

Windows Command Line Tips

Command to determine location of program in command prompt
Description from where /?
Displays the location of files that match the search pattern.
By default, the search is done along the current directory and
in the paths specified by the PATH environment variable.

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64
> where ildasm
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\ildasm.exe

Copy command output to clipboard
dir | clip

Delete all folders within a folder (Windows XP)
FOR /D %f IN ("C:\MyFolderWithOtherFolders\*.*") DO RMDIR /S /Q "%f"

Delete all folders within a folder (Windows 7, Windows Server 2008, Windows Vista)
forfiles /s /p "C:\MyTestFolder" /c "cmd /c if @ISDIR==TRUE RMDIR /S /Q @PATH"

This is a utility for selecting files and executing a command on them. Applies To: Windows 7, Windows Server 2008, Windows Vista.


Display all subfolders
forfiles /s /p "C:\MyTestFolder" /c "cmd /c if @ISDIR==TRUE echo @PATH @ISDIR"

Delete all files older than 30 days:
forfiles /p "C:\MyFolderWithFiles\" /s /m *.* /d -30 /c "cmd /c del @path"

See "Forfiles." Resources and Tools for IT Professionals | TechNet. N.p., n.d. Web. 8 Oct. 2012. <http://technet.microsoft.com/en-us/library/cc753551(v=ws.10).aspx>.

Open IIS Manager at a command prompt
  1. On the Start menu, click Run.
  2. In the Open dialog box, type inetmgr, and then click OK.
"How To: Open IIS Manager." MSDN | Microsoft Development, Subscriptions, Resources, and More. Web. 14 July 2010. <http://msdn.microsoft.com/en-us/library/bb763170.aspx>.

Commands to Display/Remove Read-Only Attributes
REM Displays files with read-only attributes set in specified directory and all subdirectories.
dir /ar /s

REM Clears the read-only file attribute from matching files in the current folder and all subfolders.
attrib -r /s

Command Line to Lock Computer (Windows 7, XP)
rundll32.exe user32.dll, LockWorkStation

2015-02-13 Added "Command to determine location of program in command prompt"
2013-08-02 Added "Copy command output to clipboard"
2012-10-08 Added "Forfiles"
2011-08-25 Added "Delete all folders within a folder"
2011-03-04 Added "Command Line to Lock Computer"

No comments:

Post a Comment