Windows (you never knows which situation you may find yourself in)

boot.ini

Process Explorer
Cygwin
Performance Monitor
Services
Batch / Shell scripting
Better Command Prompt / Shell / Terminal / Console
Windows Event Log
Grep or search

Fsutil
Sysinternal Process Explorer

https://support.microsoft.com/en-us/kb/947215
https://www.youtube.com/watch?v=KJbfe0hVXHE
http://www.vistax64.com/tutorials/130095-user-profile-service-failed-logon-user-profile-cannot-loaded.html
https://neosmart.net/wiki/corrupt-user-profile/
http://theitbros.com/fix-corrupt-windows-7-temporary-profile/
https://video.search.yahoo.com/yhs/search;_ylt=A86.J3TFQKRWnxMAO1YnnIlQ;_ylu=X3oDMTByNDN1aDMxBGNvbG8DZ3ExBHBvcwM1BHZ0aWQDBHNlYwNzYw--?p=Windows+How+To+Repair+User+Profile&fr=yhs-mozilla-001&hspart=mozilla&hsimp=yhs-001
http://www.thewindowsclub.com/repair-windows-user-profile-data-settings-with-reprofiler
https://www.youtube.com/watch?v=ML16_fwJvBo
http://www.vistax64.com/tutorials/130095-user-profile-service-failed-logon-user-profile-cannot-loaded.html
http://windows.microsoft.com/en-us/windows/fix-corrupted-user-profile#1TC=windows-7
http://www.quickonlinetips.com/archives/2010/09/how-to-fix-corrupted-user-profile-in-windows-7/

How to disable security warning for IE

http://www.gfi.com/blog/copy-paste-working-remote-desktop-connection-whats-wrong/
http://social.technet.microsoft.com/Forums/en-US/itprovistanetworking/thread/39475a5d-fc4c-4d51-87a5-bb4e3ded318e/
http://social.technet.microsoft.com/Forums/en-US/w7itprogeneral/thread/f5c77be7-5425-4f3b-94bd-0215a10ae2f2/
http://support.microsoft.com/kb/306885
http://superuser.com/questions/95609/cant-copy-and-paste-in-remote-desktop-session
http://brennan.offwhite.net/blog/2007/01/18/fixing-copypaste-for-remote-desktop-sessions/
http://www.technipages.com/unable-to-copy-and-paste-to-remote-desktop-session.html
http://blog.sqlauthority.com/2008/01/22/sqlauthority-news-fix-remote-desktop-copy-paste-stop-working/
http://blog.secaserver.com/2011/09/unable-copypaste-remote-desktop/

http://commandwindows.com/runline.htm

How can we map a network drive?

Mapping a network drive allow us to easily copy files between our local laptop to a folder on the remote server.

  1. On the remote server:
    1. Share the folder
      1. Right click on the folder and select Shared with -> Specific people. This display a dialog where you can share this folder with appropriate people. When done, click OK and take note of the shared name that it displays. If you do not remember the shared name, you can right click on the folder and select Properties and then select the Sharing tab.
  2. On the local computer:
    1. Map the drive:
      1. Click on Start -> Computer
      2. Click on Map network drive
      3. In the Drive drop-down list, select appropriate available drive letter.
      4. In the Folder input box, type the shared name including the name of the remote machine, such as \\machineName\plugins
      5. Uncheck the Reconnect at logon check box if appropriate
      6. Click Finish

How can we write a plugin for Outlook?

I don't know the answer to this question yet. Need Googling.

How can we write a program that change the desktop background image?

This program would:

  • Sit in the Windows system tray
  • Every time the user select "Show the Desktop", it would change the desktop background image to another images inside a pre-configured folder.
  • When the system is idle, it would display the desktop background images (rotating) on top of the current window but as soon as it detects user activity, it hide itself and return control to the currently active program.

On Windows 7, where does Microsoft store the desktop background images?

C:\Windows\Web\Wallpaper
C:\Users\ [YOURUSERNAME] \AppData\Local\Microsoft\Windows\Themes
C:\Users\ [YOURUSERNAME] \AppData\Roaming\Microsoft\Windows\Themes

How can we change your password over RDP?

Ctrl-Alt-End

How can we pause a running process and resume it?

CTRL+S to pause running program
CTRL+Q to resume

How can we create a symbolic link?

To create a symbolic link to an existing directory, go to the directory where you want the symbolic link to be created, and then use the mklink command:

mklink /j symbolicLinkName existingDirectory
cd C:\app\current\quantros.war
mklink /j QSRM C:\Clients\QSRM

Replace symbolicLinkName with appropriate name that you want it to be. Replace existingDirectory with the full absolute path to the existing directory that you want this symbolic link to point to.

On Windows NT, we can right click on a folder and select "Open a command prompt" here. How can we do the same thing on later versions of Windows?

Hold down the SHIFT key, right click on the folder, and select "Open command window here".

How can we remove or prevent a software from being started automatically when the system is reboot?

  1. Run msconfig.exe
  2. Switch to the Startup tab
  3. Uncheck the check box next to the software that you want to prevent being started automatically
  4. Click OK

How can we make a virtual drive and point it to an existing drive?

Subst F: C:\

I was trying to install driver for my NetGear wireless booster. It complained that drive F is invalid. NetGear web site suggest that I should create a virtual drive F and have it point to an existing drive.

How can we delete a virtual drive?

subst F: /d

How can we run a java program with administrator privileges?

Use the cmd wrapper. From the Start menu, locate the cmd, right click on it and select Run as Administrator. Now when ytou execute your java program and it will run with Admin rights.

How can we edit a file that requires administrator privileges?

If you are using Notepad++, right click on the file, select open with Notepad++, close Notepad++ without closing the file. Notepad++ will remember a list of files that are currently opened. Now from the Start menu, locate Notepad++, right click on it, and select Run As Administrator.

If you are not using Notepad++, from the Start menu, locate Notepad, right click on it, and select Run As Administrator

How can we schedule administrative tasks?

Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks

See http://support.microsoft.com/kb/308569, http://windows.microsoft.com/en-us/windows7/schedule-a-task,

How can I see a list of scheduled tasks from command line?

schtasks /query /v /fo LIST
schtasks /query /v /fo CSV > tasks.csv

schtasks.exe /change /TN pepe /ENABLE

How can we silently remove all files within a directory and remove the directory itself?

rmdir /S /Q C:\bea\user_projects\domains\quantrosDev\classfiles\jsp_servlet
rmdir /S /Q C:\bea\user_projects\domains\quantrosDev\myserver\classfiles\jsp_servlet

How can we automatically delete files that are older than 3 days?

forfiles -p "C:\what\ever\path" -s -m *.* /D -3 /C "cmd /c del @path"

Put the above command into a .bat file and use the Task Scheduler to schedule it to run once everyday.

How can we display file extension?

  1. Click on Start menu -> Control Panel -> Appearance -> Folder Options
  2. Click on View
  3. Uncheck the checkbox "Hide extensions for known file type"

How can we display hidden files?

  1. Click on Start menu -> Control Panel -> Appearance -> Folder Options
  2. Click on View
  3. Click on "Show hidden files, folders, and drives" radio button

How can we give a user access to RDP:

  1. Launch the Control Panel
  2. Click on User Account -> Give other users access to this computer
  3. Click on Add
  4. Click on Browse
  5. Provide the user ID
  6. Click on Check Names
  7. Click OK
  8. Back on the main User Account, click on Advanced
  9. Click on Advanced (in the middle section)
  10. Click on Groups
  11. Right click on Remote Desktop Users, and select "Add to Group"
  12. Click on Add
  13. Provide the user ID
  14. Click on Check Names
  15. Click OK

How can we set environment variable from command line?

set TESTK="Hello"

What is the purpose of the setx command?

It is for setting environment variable:

setx JAVA_HOME=<PATH>

When you change an environment variable by using the Windows setx command, you must close and reopen the Command Prompt window for the change to take effect.

How can we configure environment variables via the GUI?

  1. Click on the Start menu
  2. Right click on Computer
  3. Select Properties
  4. Click on "Advanced system settings" (on the left top corner)
  5. Click on the "Environment Variables" button at the bottom
  6. If you wish to add the new environment variable such that it is available to all users, click on the "New" button under the "System Variables" section
  7. Specify the name and value for the new variable and click OK.

How can we display the value of an environment variable from command line?

echo %TESTK%

If the environment variable is not defined, you will see the string %TESTK% displayed on the screen.

How can we display all environment variables?

set

How can we display uptime information (when the server was last rebooted)?

net statistics server
net stats srv

The line that start with "Statistics since …" provides the time that the server was up from. Uptime.exe Tool Allows You to Estimate Server Availability with Windows NT 4.0 SP4 or Higher.

How can we transfer files via RDP?

If you are not able to copy files via RDP, you can create shared network drive. For example, if you need to copy files between your development workstation and your production server, on the production server, create a shared network drive and assign appropriate access privilege. From your development workstation, open Windows Explorer and navigate to \\PRODUCTION_SERVER_IP. You can now copy files between your development workstation and your production server.

Look under Administrative tools > Terminal Services Configuration > Connections > RDP-Tcp > Client Settings > see what is under Disable the following mainly Drive Mapping. But this should apply to all users so if the above is correct this shouldn't work.

Using xcopy to copy files between drives:

Xcopy /S /I /E /H /J D:\data\documents E:\Newfolder\documents
xcopy /R /F /C /V /E /H  d:\ e:\ 

/v : verify the file after copying
/f : Displays source and destination file names while copying.
/s : Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory. 
/e : Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options. 
/t : Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the /e command-line option. 
/k : Copies files and retains the read-only attribute on destination files if present on the source files. By default, xcopy removes the read-only attribute. 
/z : Copies over a network in restartable mode. 
/j : Copies files without buffering. Recommended for very large files.

// To copy all the files and subdirectories (including any empty subdirectories) from drive A to drive B, type: 
xcopy a: b: /s /e 

// To include any system or hidden files in the previous example, add the/h command-line option as follows:
xcopy a: b: /s /e /h

// Copy source to destination including empty folder
robocopy source destination /E

// Mirror A to B, destroying any files in B that are not present in A (/MIR), and 
// copy files in resume mode (/Z) in case network connection is lost:
robocopy source destination /MIR /Z

// For robocopy, source and destination must be the name of folder.  If you need to
// copy a single large files to a remote computer, you must first put this large file
// on your local computer into a folder if it is not already inside a folder.

Where is the host / lmhost file?

%SystemRoot%\System32\Drivers\Etc

How can we schedule a task / job to be run regularly:

Start > Programs > Accessories > System Tools > Scheduled Tasks

See http://drupal.org/node/31506

How can we use netstat:

netstat -a -no
tasklist

See Apache won't start on XAMPP

How can we kill a process that is listening on a particular port?

netstat -a -n -o | findstr :8080
taskill /F /PID nnn

How can we display the name of the executable that is listening on a particular port?

netstat -a -n -o -b

How can we renew your IP address:

ipconfig /renew

How can we find our internal IP address:

ipconfig

If you IP address was renewed, but your internal DNS is not updated, how can we update your internal DNS server?

My desktop was given a name doan1, and from any computer at work, I was able to access the web server running on my desktop via http://doan1:7001/. However, at one time, I need to plug the ethernet cable into a different hub / switch, and I needed to renew my internal IP address. After renewing the IP address, I was able to RDP into my desktop using the new IP address, however I was not able to use my machine name doan1, because the internal DNS server for the company was not updated, and nslookup doan1 from the command line returned the old IP address. To register my new IP address with the company internal DNS server (which is not running on my desktop):

ipconfig /registerdns

How can we recover the console for Microsoft Virtual PC?

Remove C:\Documents and Settings\kdoan\Application Data\Microsoft\Virtual PC\Options.xml

How can we redirect both STDOUT and STDERR to the same file?

C:\solr.1.4.1>"C:\Program Files\Java\jre6\bin\java" -Dsolr.solr.home=solr -jar start.jar > out.txt 2>&1

See Recovering a lost Virtual PC Console, and A Comprehensive Test Strategy for Internet Explorer 6, 7 and 8

How do I run a bat file in the background from another bat file?

test.cmd:

@echo off
call "cmd /c start test2.cmd"
call "cmd /c start test3.cmd"
echo Foo
pause

test2.cmd:

@echo off
echo Test 2
pause
exit

test3.cmd:

@echo off
echo Test 3
pause
exit

Combine that with parameters to start, such as /min if you don't want the new windows to spawn in front of you.

Standard, inline approach: (i.e. behaviour you'd get when using & in Linux)

START /B CMD /C CALL "foo.bat" [args [...]]

Notes: 1. CALL is paired with the .bat file because that where it usually goes.. (i.e. This is just an extension to the CMD /C CALL "foo.bat" form to make it asynchronous. Usually, it's required to correctly get exit codes, but that's a non-issue here.); 2. Double quotes around the .bat file is only needed if the name contains spaces. (The name could be a path in which case there's more likelihood of that.).

If you don't want the output:

START /B CMD /C CALL "foo.bat" [args [...]] >NUL 2>&1

If you want the bat to be run on an independent console: (i.e. another window)

START CMD /C CALL "foo.bat" [args [...]]

If you want the other window to hang around afterwards:

START CMD /K CALL "foo.bat" [args [...]]

Note: This is actually poor form unless you have users that specifically want to use the opened window as a normal console. If you just want the window to stick around in order to see the output, it's better off putting a PAUSE at the end of the bat file. Or even yet, add ^& PAUSE after the command line:

START CMD /C CALL "foo.bat" [args [...]] ^& PAUSE

& is an "and then" (terminology?) operator. (e.g. cmd1 & cmd2 means do "cmd1" and then "cmd2". Unlike the && operator, execution of "cmd2" doesn't depend on the successful exit of "cmd1".) The ^ escapes the & so that it goes into CMD's arguments instead of being consumed and run by the same console that ran START.

This works in my XP home:

call notepad.exe &

Since START is the only way to execute something in the background from a CMD script, I would recommend you keep using it. Instead of the /B modifier, try /MIN so the newly created window won't bother you. Also, you can set the priority to something lower with /LOW or /BELOWNORMAL, which should improve your system responsiveness.

It is not creating a new window because you're using the /B flag. Remove it.

If you want your batch file to close its window when it finished:

1. Put The Command EXIT in the end of the bat file.
2. Then Do Right Click On The Bat File Then Go To Properties -> Program There You Will See A Check Box.  With The Label "Close On Exit" Make Sure It Is Mark On

Try using the call or start command to invoke one batch from another. Syntax:

CALL batch.bat
or
START batch.bat

This will shell out and exit the shell it is in:

cmd /q /c "net use lpt1 /delete > nul"
cmd /q /c "net use lpt1 \\dynamics\xerox > nul"

Add a CLS at the end of your batch code to clear the screen. This will cause the DOS window to close since there's nothing to display when it's done. Hope that helps.

How can we start a batch script after the user log in?

Refer to the second half of http://www.windowsnetworking.com/articles_tutorials/nettime.html, and http://www.howtogeek.com/howto/windows/hide-flashing-command-line-and-batch-file-windows-on-startup/

How can we configure the default folder view or make all folder views the same so they all look consistently?

  1. Open a folder (C drive)
  2. Click the View menu
  3. Select the type of view you want (large, small, details, list, etc.)
  4. Click the View menu again
  5. Select Arrange Icons
  6. Select the type of arrangement (by name, by date, etc)
  7. Look at your folder view. This will be the folder view that you are going to set as your default folder view if you continue. If you are not happy, continue to adjust the methods of viewing and arranging. Then continue.
  8. Click the Tools menu
  9. Click Folder Options
  10. Click View tab
  11. Click Apply to All Folders

How can we run a program with administrator privileges?

Right click on the program and select "Run as administrator"

How can we sync time:

w32tm /resync

To specify / configure which time server should be used:

net time /setsntp:time.nist.gov

To see which time server is being used:

net time /querysntp

Run a program with the specified date/time:

Using Microsoft Virtual PC:

How can we add something to the Windows registry?

  1. Run the Registry Editor (regedit) command
  2. Drill down on the node (on the left hand side) where you want to make the change
  3. Right click on the node and appropriate option
  4. On the right side, select the appropriate key, right click on it, and select appropriate option
  5. Changes made are automatically saved.
  6. Close the Registry Editor

How can we export a key from the Windows registry?

  1. Run the Registry Editor (regedit) command
  2. Drill down on the node that you want to export (on the left hand side)
  3. Right click on the node that you want to export (on the left hand side)
  4. Select Export
  5. Specify the file name
  6. Click OK / Save
  7. Right click on the file and edit it with Notepad++ (remove all the keys except for the one that we just added, save the file, and exit Notepad++)

How can we import a key into the Windows registry?

  1. Double click on the .reg file.

How can we track registry and file changes when installing new software:

When we install a software on Windows, it usually comes with an installer. The installer extracts a lot of files to the default location, normally in C:\Program Files. Some will even drop a few critical driver files in the Windows folder. Some will add keys into Windows registry.

Regshot is a free tool that can be used to track file and registry changes. Use Regshot to create the initial snapshot of the file system and the registry before installing the software. After installing the software, use Regshot again to create the post-install snapshot, and view the changes. Intially, Regshot can only track registry changes, but since version 2.0.1.56, the developer added Fileshot which can also track file changes. Fileshot is disabled by default, and you will have to enable it from the Options menu. Fileshot checks for changes using MD5 and CRC32. After comparing the first and second snapshots, it'll open up a detailed HTML log on what has been changed on your computer.

How can we access network resources using file URLs inside HTML page?

How can we search for files on Windows?

The indexing service on Windows can be tweaked / tuned. By default, it is configured to index the entire hard drive. This makes it easy to find files that are located anywhere on the system. However, this make searching for file slow. To make searching fast, keeps all the files that you need to search on in one directory (you can have sub-directories inside), and configure the indexing service to only index that directory:

  1. Click on Start -> Run
  2. Type Ciadv.msc into the box and hit enter
  3. Click on "Show / Hide Console Tree"
  4. Select the Directories folder in the tree to see a list of all the directories the service is configured to monitor
  5. From inside this tool, remove all the default directories from the index (right click on the directory and select 'Delete')
  6. Add your directory to the index (right click anywhere, select 'New -> Directory', browse for your directory, and specify yes for 'Include in Index?')

At this point, minimize the indexing service console, locate your folder, right click on the folder, and select Properties -> Advance -> For fast searching, allow Indexing Service to index this folder, and click OK. Return to the Indexing Service console, select "Indexing Service on Local Machine", and click on "Start Indexing" button on the toolbar. Depending on the number of documents you have in your directory, it may takes awhile for the Indexing Service to index your directory. While the indexing operation is running, it will let you know its status via the status column. When the indexing operation is complete, the status column will list the operation as Started. You can then close the Indexing Service console, launch the search tool and begin searching. To launch the search tool, locate your folder, right click on your folder and select 'Search'. In the search dialog, type your text into the second box (A word or a phrase in the file).

It seems that the search operation is a bit unpredictable, and it does not do stemming.

If you are using Windows XP and Windows Search 4.0, there should be a small icon on the system tray. When you right click on this icon, it should give you an option "Windows Search Options". Using this option, you can control which directories should be indexed. Click on this option, and click on Modify. The bottom half of this screen display a list of included locations. The top half allows you to drill down on the directories so that you can select which directories should be indexed. By default, Windows Search 4.0 will index Internet Explorer History, which make clearing IE cache extremely slow, and however we cannot prevent Windows Search from indexing Internet Explorer History from this screen. To prevent Windows Search from indexing Internet Explorer History, launch IE, click on Tools -> Internet Options -> Content, and click on Settings (in the AutoComplete section), and uncheck the "Use Windows Search for better results"

Windows Search 4.0, by default, will index your emails (if you are using Outlook), which is nice. It makes searching email a lot faster. Without Windows Search 4.0, the search functionality in Outlook is terribly slow. Xobni helps, but also has one issue (if we type a name into the To box, it takes forever to pull up the list of recipient).

taskkill /fi "WINDOWTITLE eq startWebLogic"
taskkill /im iexplore.exe
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Reading / Writing Windows Registry:

How can we install telnet client?

  1. Start Server Manager. Click Start, right-click Computer, and then click Manage.
  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  3. In the Features Summary section, click Add features.
  4. In the Add Features Wizard, select Telnet Client, and then click Next.
  5. On the Confirm Installation Options page, click Install.
  6. When installation finishes, on the Installation Results page, click Close.

How can we boot into safe mode?

  1. Turn off the machine
  2. Press and release the power button
  3. Press and hold the F8 key
  4. Select appropriate safe mode using the up and down arrow keys and hit the ENTER key

How can we enable the built-in administrator account?

  1. Click on the Start menu
  2. Type cmd
  3. Right click on cmd and select "Run As Administrator"

Then in the command prompt window:

net user administrator /active:yes

How can we disable the built-in administrator account?

Make sure you are not logged into the built-in Administrator account when trying to disable it. You must be logged into a normal administrator account to do this instead. It will not work if you try to disable the built-in Administrator account while you are still logged on to it.

  1. Click on the Start menu
  2. Type cmd
  3. Right click on cmd and select "Run As Administrator"

Then in the command prompt window:

net user administrator /active:no

What is the purpose of the runas command?

runas /usr:username command
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License