Digital Sanctum

Personal blog of Shane Witbeck Tags · Archive · About

Stupid Windows Tricks from the command line

Published: 13 Jun 2008

Change the Log on credentials for a windows service:

sc.exe config "YourServiceName" obj= "yourusername" password= "yourpassword"

Bring up services:


Copy a directory structure:

xcopy G:\foo\*.* D:\bin\bar /E /D /Y

Copy a directory structure and exclude one or more files/directories:

xcopy \\nyceqasp8081\apps\polyent\*.* D:\apps\bar\ /E /D /Y /EXCLUDE:excludefile.txt

where excludefile.txt is a file containing one or more path exclusions for example D:\apps\bar\logs

Set environment variables:

setx JAVA_HOME "D:\bin\Java\jdk1.5.0_12" /m

The /m here denotes the variable should be a system wide variable. Leaving /m off will add the variable to the current user’s environment instead.

Map a drive and make it persistent (after reboots):

net use G: \\\spg /P:Yes

Note: These have been tested and known to work on Windows Server 2003. Your mileage may vary on other variants of Windows.

Tags: #windows#command-line