Archive

Posts Tagged ‘cmd’

Clearing out corrupt print jobs REDUX

April 1, 2009 Leave a comment

Batch IconQuick update to clearing out print jobs.  Got a call this morning from a user who repeatedly gets jobs stuck in their print queue.  To help reduce his calls, I wrote this quick batch and put it on his desktop.

@ECHO OFF
ECHO Repairing Printer… Please wait….
Net stop spooler
del /Q c:\windows\system32\spool\printers\*.*
net start spooler
cls
ECHO Please powercycle your printer
ECHO …
ECHO Printer is repaired
pause

Try it out!

Advertisements

Using Taskkill to kill muliple instances of Outlook.exe

March 26, 2008 1 comment

Taskkill ScreenshotEver run across a PC where outlook wont open, and the user has clicked on it about 50 times.  Lone behold when you open task manager there is actually 50 instances of outlook.exe running.  Instead of clicking “end task” for each of these, just open your friendly command prompt and type in this command

taskkill /IM “outlook.exe” /f

This will kill all of your outlook.exe’s forcefully.

RCMD, the remote command prompt

March 24, 2008 1 comment

Batch IconOne of the most powerful parts of windows is the command line interface (cmd.exe). I have done things from directory listings to adding users locally, editing registry and even as far as manipulating windows services.

Being able to do all this from command line is great, but when you have multiple machines at different locations, It is nice to do some remote work from time to time. In comes PSEXEC from Microsoft’s Sysinternals. using PSEXEC and a little know-how on writing batch files, I created a batch file that will allow me to use the command line interface on remote PC while the user is still logged on.

The batch is as follows

psexec //%1 -u domainname\user -p password c:\windows\system32\cmd.exe

pause

saving this batch file as c:\windows\rcmd.bat will allow you to start the run command and type rcmd computername and you should get a command prompt for that PC (if you are an administrative user on that PC)

This is great for spot checks or quick changes, but when you want to make changes, but when you need to make changes on more than one PC, you can create a batch file with these changes and use PSEXEC to run the batch on a list of workstations.

First you want to create a text file (I call mine hosts.txt) and input each computer name or IP of the workstation (one host per line)

Next is to open up a command line and type in the following

psexec @hosts.txt -u domain\user -p password -c batchfile.bat

To keep things neat and tidy, I generally creatediscriptive folder with psexec, the batch file, the hosts file and a batch including this command called runme.bat.