Solved

C# Logoff Users Remotely

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

20 Experts available now in Live!

Get 1:1 Help Now