ShutDown Computer
-
What can i do to shut down a computer near me ( on the LAN 1network ) Thanks Rock Throught The Night
-
What can i do to shut down a computer near me ( on the LAN 1network ) Thanks Rock Throught The Night
First, the account your running your app under must have Remote Shutdown privileges on the target machine to shut it down. After all, you can't just be any old user and shutdown someones else's machine. Next, you'd have to P/Invoke the
InitiateSystemShutdownEx
API call with the name of the target computer to shutdown. Docs on this call begin here[^]. A little extra C# specific information can be found on PInvoke.net here[^]. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -
First, the account your running your app under must have Remote Shutdown privileges on the target machine to shut it down. After all, you can't just be any old user and shutdown someones else's machine. Next, you'd have to P/Invoke the
InitiateSystemShutdownEx
API call with the name of the target computer to shutdown. Docs on this call begin here[^]. A little extra C# specific information can be found on PInvoke.net here[^]. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome:confused: Why did that get voted down? Seemed like a reasonable answer to me. (I didn't know how to do this before as I've never had the need to find out but it seems a reasonable answer)
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog
-
:confused: Why did that get voted down? Seemed like a reasonable answer to me. (I didn't know how to do this before as I've never had the need to find out but it seems a reasonable answer)
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar The Second EuroCPian Event will be in Brussels on the 4th of September Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way! My Blog
Probably because I didn't supply any actual source code. Hey, I thought the DllImport line on PInvoke was hint enough. That line plus one more line of code to actually execute it and your done. But I guess that's what I get for forcing someone to do a little work to learn something. I just don't have to the time to write a sample app for every single post, but, apparently, some people expect that. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Probably because I didn't supply any actual source code. Hey, I thought the DllImport line on PInvoke was hint enough. That line plus one more line of code to actually execute it and your done. But I guess that's what I get for forcing someone to do a little work to learn something. I just don't have to the time to write a sample app for every single post, but, apparently, some people expect that. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Surprised? Some seem to expect that we do their work for them. Besides, just type "shutdown" in the MSDN search (or better yet, if available, start typing "Shutdown" in the MSDN Library index) and you'll find lots native APIs you can P/Invoke (and you even gave him a link to the signature!). I'll vote you up to counter-act the response (my vote would be more "weighty" than some n00b anyway :)). Don't fret, Dave, some people are just like that. I had a couple guys the other day (in fact, the guy that responded directly below this thread, a self-proclaimed CEO of some company who's logo looks like it was drawn in mspaint.exe) get really pissed off and call me names because several times I asked someone to ellaborate on "it doesn't work". :rolleyes: Also, you can do this with WMI and avoid the marshaling (though you incur a performance hit with WMI itself). Just FYI. :)
Microsoft MVP, Visual C# My Articles
-
Surprised? Some seem to expect that we do their work for them. Besides, just type "shutdown" in the MSDN search (or better yet, if available, start typing "Shutdown" in the MSDN Library index) and you'll find lots native APIs you can P/Invoke (and you even gave him a link to the signature!). I'll vote you up to counter-act the response (my vote would be more "weighty" than some n00b anyway :)). Don't fret, Dave, some people are just like that. I had a couple guys the other day (in fact, the guy that responded directly below this thread, a self-proclaimed CEO of some company who's logo looks like it was drawn in mspaint.exe) get really pissed off and call me names because several times I asked someone to ellaborate on "it doesn't work". :rolleyes: Also, you can do this with WMI and avoid the marshaling (though you incur a performance hit with WMI itself). Just FYI. :)
Microsoft MVP, Visual C# My Articles
<soapbox><blowOffSteam> I know what I did wrong! I didn't write up a Whitewaper on the the use of System Shutdown functions. The various methods that could be used, and their pro's and con's. Can't forget to cover the security concerns, and OOOh!, AbortSystemShutdown. Need to add a plethora of sameple code too and a couple of complete apps. Hey! Sounds like an article for CP! :rolleyes: I haven't written an article yet, just because of the abuse that comes back when not evey single person who read your article got everything they were looking for, like Cut & Paste source. I'm still debating wheather or not I want to put in the time to do that, then put up with a bunch of n00b's who don't have a clue what they're doing, insisting your code doesn't work. Oh! And if it does work, it doesn't work exactly the way they want it. </blowOffSteam></soapbox> I've seen that logo. Man, 30 seconds work in Photoshop, MSPaint would have taken longer... and just because your the only person at the company, it doesn't make you a CEO, but your garanteed to be the mail boy! But, we keep coming back here doing this day after day because we have this need to want to help people. I'd have to say it's kind of an addiction for me! ;P My girlfriend can attest to that! :laugh: Oh well, back in the trenches I go! I've even got a couple of ideas for some articles... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
<soapbox><blowOffSteam> I know what I did wrong! I didn't write up a Whitewaper on the the use of System Shutdown functions. The various methods that could be used, and their pro's and con's. Can't forget to cover the security concerns, and OOOh!, AbortSystemShutdown. Need to add a plethora of sameple code too and a couple of complete apps. Hey! Sounds like an article for CP! :rolleyes: I haven't written an article yet, just because of the abuse that comes back when not evey single person who read your article got everything they were looking for, like Cut & Paste source. I'm still debating wheather or not I want to put in the time to do that, then put up with a bunch of n00b's who don't have a clue what they're doing, insisting your code doesn't work. Oh! And if it does work, it doesn't work exactly the way they want it. </blowOffSteam></soapbox> I've seen that logo. Man, 30 seconds work in Photoshop, MSPaint would have taken longer... and just because your the only person at the company, it doesn't make you a CEO, but your garanteed to be the mail boy! But, we keep coming back here doing this day after day because we have this need to want to help people. I'd have to say it's kind of an addiction for me! ;P My girlfriend can attest to that! :laugh: Oh well, back in the trenches I go! I've even got a couple of ideas for some articles... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
Dave Kreskowiak wrote: and just because your the only person at the company, it doesn't make you a CEO, but your garanteed to be the mail boy! :laugh::laugh::laugh: Excellent! :laugh::laugh::laugh: I'm an addict, too, though my contant work schedule drives me away from my computer most times to spend time with my wife*. I just like to help people, and we've both gotten times where people actually take the time to respond and say "thank you". I like that and it shows that there are still decent people left who, while they may not be able to solve their problem themselves (and no one can all the time anyway), they are willing to accept any help and are grateful. * The guy actually had the nerve to say that posting 1,000 / month is something I shouldn't boast about (which I wasn't, merely pointing out the fact that he and his little buddy are wasting my time - not vice versa - by saying "it doesn't work" and expecting me to debug their code for them) and that's why I spend so many lonely nights. I mean, if you're going to attack someone's character, you should at least check their bio. I think being married would definitely be an indication of not spending lonely nights. :rolleyes: It's good to blow off some steam sometimes, huh? :) After all the time you I, and a few others put into this forum, pressure and irritation are bound to build-up. I mean, we're only human (at least that's the guise I stick to).
Microsoft MVP, Visual C# My Articles
-
Dave Kreskowiak wrote: and just because your the only person at the company, it doesn't make you a CEO, but your garanteed to be the mail boy! :laugh::laugh::laugh: Excellent! :laugh::laugh::laugh: I'm an addict, too, though my contant work schedule drives me away from my computer most times to spend time with my wife*. I just like to help people, and we've both gotten times where people actually take the time to respond and say "thank you". I like that and it shows that there are still decent people left who, while they may not be able to solve their problem themselves (and no one can all the time anyway), they are willing to accept any help and are grateful. * The guy actually had the nerve to say that posting 1,000 / month is something I shouldn't boast about (which I wasn't, merely pointing out the fact that he and his little buddy are wasting my time - not vice versa - by saying "it doesn't work" and expecting me to debug their code for them) and that's why I spend so many lonely nights. I mean, if you're going to attack someone's character, you should at least check their bio. I think being married would definitely be an indication of not spending lonely nights. :rolleyes: It's good to blow off some steam sometimes, huh? :) After all the time you I, and a few others put into this forum, pressure and irritation are bound to build-up. I mean, we're only human (at least that's the guise I stick to).
Microsoft MVP, Visual C# My Articles
Heath Stewart wrote: I mean, we're only human (at least that's the guise I stick to). :rolleyes: I won't tell anyone! It's good to hear a "Thank You" now and then. It helps us to keep coming back for more! Anyway... Thanks Heath! Keep posting the GREAT work! I'm learning something new from you every day! I've gotta get out of here, go wine and dine the little woman, and get in some cuddle time! See y'all tomorrow! :-D RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome