C
C#2y ago
goooosee

❔ how to turn off computer 1 from computer 2 with his ip and connected to the same network

hello how do i shutdown a computer remotly with ip? shutdown /m \{IP}/s /t 3 thats what im doing in cmd but when i try do the same in c# it doesnt work
23 Replies
Thinker
Thinker2y ago
What are you making?
JakenVeina
JakenVeina2y ago
what do you mean "do the same in C#"? do that how?
goooosee
gooooseeOP2y ago
im making an office computer manager
goooosee
gooooseeOP2y ago
okay so this command will shutdown the computer right
JakenVeina
JakenVeina2y ago
if you say so
goooosee
gooooseeOP2y ago
and im trying to open the cmd print that and make it shutdown the computer i tried chatgpt but it was not working
JakenVeina
JakenVeina2y ago
you said you are doing "the same in C#" how?
goooosee
gooooseeOP2y ago
oh well nvm i try to make the cmd open in c# and then pass all data
JakenVeina
JakenVeina2y ago
yes how how are you doing this? what about this isn't working?
goooosee
gooooseeOP2y ago
Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.Arguments = $"/c shutdown /m \\{ip} /s /t 3"; process.Start(); thats how i do that
JakenVeina
JakenVeina2y ago
and what's not working about that?
goooosee
gooooseeOP2y ago
well its not turning off the computer xd i dont get any c# errors its just not working
JakenVeina
JakenVeina2y ago
no errors or anything? just silent failure?
goooosee
gooooseeOP2y ago
yep
JakenVeina
JakenVeina2y ago
k well, for starters, what you posted is in-fact not the command to shutdown a remote computer according to the docs it's
shutdown /m \\<computername> /s /t 3
shutdown /m \\<computername> /s /t 3
goooosee
gooooseeOP2y ago
wait i dont need ip?
JakenVeina
JakenVeina2y ago
you need <computername> which isn't explicitly documented on what values it can be but presumably, yes, it could be an IP or a hostname or a URL
goooosee
gooooseeOP2y ago
its weird because it worked when i did it in cmd
JakenVeina
JakenVeina2y ago
the next question would be "what permissions is this program running with?"
goooosee
gooooseeOP2y ago
non admin does it need it?
JakenVeina
JakenVeina2y ago
it needs whatever permissions are needed to run the command so, yeah
goooosee
gooooseeOP2y ago
shit lol i thought it wont need it because its just passing some letters into cmd sadly i dont have second computer rn well thanks!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server