Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# Logoff Users Remotely

Posted on 2013-11-15
2
Medium Priority
?
965 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

722 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