Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 2008

PsExec to the Rescue

Using PsExec instead of Terminal Services Manager to access a remote server has its advantages
RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

In my previous position, I sometimes had to grant temporary access to remote servers to the administrators of other departments in that company. Sometimes these administrators forgot to log off the remote server after they completed their tasks, thus locking out other administrators when the Windows Server 2003 Terminal Services session limit had been reached. Usually the offending administrators were out to lunch or had left for the day. This always seemed to happen when there was a problem that needed immediate attention on that server. Typically, I had used Terminal Services Manager to log off the administrator. However, there were times when that wasn’t an option because the remote server I needed to access was the one running Terminal Services Manager.

When I was searching the Internet for a solution to this problem, I came across a discussion of the PsExec tool in the Windows Power Tools column “PsExec” (July 2004, InstantDoc ID 42919). PsExec lets you launch interactive command-prompt sessions and run programs on remote systems without having to install client software on those systems. This tool looked promising, so I downloaded the latest version from the Microsoft TechNet website (technet.micro soft.com/en-us/sysinternals/bb897553.aspx).

I decided to try PsExec in a test environment. I ran a command that followed the syntax

C:\psexec \\ServerName
  -u Domain\UserID cmd
where ServerName was the name of the remote server I needed to access and Domain UserID was the username I wanted to use to log on to that server. The cmd argument told PsExec to launch an interactive command-prompt session on that server.

After I entered my password, the remote server’s command-prompt window appeared. I then ran the Query Session command:

Query Session
The output showed the user IDs of the administrators who were connected to the server. I was then able to use the following Logoff commands with the administrators’ IDs to log off those administrators:
Logoff 2
Logoff 3
Afterward, I reran the Query Session command to see if those administrators were logged off. The Logoff commands were successful.

Because this was a test environment, I knew that the administrators I logged off weren’t running any important tasks on the remote server. However, in a production environment, you need to make sure that the administrator you’re about to log off isn’t running an important task. You can use the Tasklist command to check which tasks are running and who is running them. Assuming you’re still logged on to the remote server, you can use the command

Tasklist /v /fi "STATUS eq running"
From that point on, I used PsExec to log off administrators on all remote servers. Using Terminal Services Manager to access a remote server takes a couple of minutes, whereas using PsExec takes only a couple of seconds. As this practical usage of PsExec demonstrates, sometimes you need to keep an open mind and think beyond GUIs.

—Tim Bolton, Microsoft infrastructure technician, Lightedge Consulting Services

End of Article



Reader Comments
Good article TIm. One more reason to "Let the ways of the command prompt", and since TS is still a big part of our life I hope you cover other non GUI ways to negate the errors of the "carbon units".
Curt Spanburgh

SCG October 03, 2008 (Article Rating: )


Great article Tim. Thanks for sharing this gem. Congrats on the first of many I'm sure.

MrEclipseguy October 04, 2008 (Article Rating: )


psexec is a valuable tool but for the above tasks it is not necessary. builtin tools, such as tskill.exe and logoff.exe both supports remote logoff.

Murat Yildirimoglu

muraty October 07, 2008 (Article Rating: )


Great. I have many more examples of the amazing and talented psexec at work. I should document them some time.

netmarcos,netmarcos October 08, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Microsoft Kills OneCare, Will Launch Free Security Solution

Microsoft on Tuesday announced that it would retire its $50-a-year security subscription product, Windows Live OneCare, and replace it with a free solution codenamed "Morro." Unlike OneCare, however, Morro will focus only on core anti-malware features and ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

The website is down because someone removed the X-Box

What happens when a manager mistakes a server for a games console. ...


Related Articles Yet Another 8 Absolutely Cool, Totally Free Utilities

8 More Absolutely Cool, Totally Free Utilities

PsExec, User Account Control and Security Boundaries

8 Absolutely Cool, Totally Free Utilities

Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing