Solved

C# Logoff Users Remotely

Posted on 2013-11-15
2
837 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now