Solved

C# Logoff Users Remotely

Posted on 2013-11-15
2
885 Views
Last Modified: 2013-11-18
I have an issue where one of our servers is diplaying the following message:

"A device attached to the system is not functioning"

Under any other instance I would just attached to server manager and logoff the users to clear the error.  But in this instance I found that this server is actually not on the domain and it host 10 production Hyper-V hosts.

Is there a way that I can do this through either a script or C#.  I tried using the shutdown /l command but I get access denied because I have no options to specify a username or password

Thank you all of your help in advance
0
Comment
Question by:thomasm1948
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 500 total points
ID: 39655785
hi... Can you use this...

System.Diagnostics.Process.Start("shutdown.exe", String.Format(@"/l /f /m \\{1}", remoteComputerName));

/l is logoff. /f is force. /m \\computername is the name of the remote computer to do the operation on. If you are not on a domain and the user running the app does not have domain admin rights I can not guarantee the above command will work.

Another option: get PsExec then run the shutdown command with it on the remote computer(shutdown.exe /l /f)
0
 

Author Closing Comment

by:thomasm1948
ID: 39657934
I tried these.  The only option that worked was to restart the server being that the server is not part of the domain.  That is why I was looking for an option that gives you an option to inout a username and password
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help with another query 10 54
asp.net repeater 2 37
Cannot locate cell 15 42
XML Constructor Throwing Incorrectly Structured Document Error 4 23
In this post we will learn different types of Android Layout and some basics of an Android App.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question