CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
Shutting down Win2K from Perl

 



Jean
User


Jun 24, 2002, 6:54 AM

Post #1 of 12 (7892 views)
Shutting down Win2K from Perl Can't Post

Yesterday I was looking for the Windows API function for shutting down my Win2K and couldn't find one. Could someone post the solution (I don't insist on using the API - the esier, the better).

Thanks in advance...


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


fashimpaur
User

Jun 25, 2002, 10:06 AM

Post #2 of 12 (7887 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

Jean, I thought I had posted this to you yesterday, but it seems to have
disappeared.

From the Perl Documentation at Activestate.com:

see http://aspn.activestate.com/ASPN/Products/ActivePerl/lib/Win32.html


Quote
Win32::InitiateSystemShutdown
(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)

[EXT] Shutsdown the specified MACHINE, notifying users with the supplied MESSAGE, within the specified TIMEOUT interval. Forces closing of all documents without prompting the user if FORCECLOSE is true, and reboots the machine if REBOOT is true. This function works only on WinNT.

This says it only works for NT but it may work for Win2000. I don't find much other than that. Maybe you can find the kernel.dll and pertinent docs to
find out how to use Win32::API to do this.

Good Luck,
Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";


Jean
User


Jun 26, 2002, 1:20 AM

Post #3 of 12 (7884 views)
Re: [fashimpaur] Shutting down Win2K from Perl [In reply to] Can't Post

10x Dennis,

That's what I was looking for - earlier I have scanned the Visual Studio's Windows API reference and everything under Win32 in perldoc except the Win32 itdelf - and for some obscure reason :-) didn't find the function that performs the shutdown.
Right now I'm doing this with shutdown.exe (something similar to the one) from the Win2K resource kit, but it's not cool. I'm sure Win32::InitiateSystemShutdown will work for Win2K - they mention the WinNT as opposed to Win95/98 etc.

Thanks again,


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


Jean
User


Jun 30, 2002, 5:12 AM

Post #4 of 12 (7876 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

It works almost as expected - the funny part is that it stays on "you may shut down your computer" (or some such) without actually powering down :-(

So I guess I'll stick to the original solution...


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


yapp
User

Jul 6, 2002, 3:49 AM

Post #5 of 12 (7864 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

WIndows NT, 2K has a 'shutdown' command.

Type 'help shutdown' or 'shutdown /h' in the dos-prompt for details.

You can run this command from Perl with the system() function.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Jean
User


Jul 6, 2002, 11:29 PM

Post #6 of 12 (7861 views)
Re: [yapp] Shutting down Win2K from Perl [In reply to] Can't Post

It's located in the Win2K resource kit :-(
Until now I couldn't get hold of a copy, but the utility I'm working with is basically
identical to the one from the resouce kit, so it doesn't matter which one I'm using.

Thanks for the advice though...


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


(This post was edited by Jean on Jul 6, 2002, 11:31 PM)


yapp
User

Jul 7, 2002, 2:31 AM

Post #7 of 12 (7858 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

What about


Code
system("$ENV{WINDIR}/RUNDLL32.EXE user.exe,exitwindows");


I just rememberd I have such nice shortcut in my quick-launch bar Smile

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Jean
User


Jul 7, 2002, 4:16 AM

Post #8 of 12 (7856 views)
Re: [yapp] Shutting down Win2K from Perl [In reply to] Can't Post

I'll try it at home, but sounds promising ;-)


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


Jean
User


Jul 15, 2002, 11:31 PM

Post #9 of 12 (7847 views)
Re: [yapp] Shutting down Win2K from Perl [In reply to] Can't Post

That's what I was looking for in the first place ;-)

What I need is the exitwindowsEX function (this one actually performs a shutdown).
My problem is that the function requires a couple of parameters (Visual Studio's API Text Viewer states so) and the question is how do I pass the params to the function is such a call?


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


Jean
User


Jul 15, 2002, 11:41 PM

Post #10 of 12 (7845 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

Moreover, the question is "what values should I pass?"...


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


yapp
User

Jul 20, 2002, 12:15 PM

Post #11 of 12 (7833 views)
Re: [Jean] Shutting down Win2K from Perl [In reply to] Can't Post

Oh? Shocked At windows 98, I have a shortcut in my quick-lauch having the following target:

C:\WINDOWS\RUNDLL32.EXE user.exe,exitwindows

Try making that shortcut... If that works, it could also work with Perl.

I know about the ExitWindowsEx function, but passing parameters..? I don't know. Guess it isn't even possible... Maybe some of the guys at M$ have some explaination of rundll32.exe (for example at http://msdn.microsoft.com/library) But that's a wild guess.. Unsure

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


Jean
User


Jul 20, 2002, 10:53 PM

Post #12 of 12 (7829 views)
Re: [yapp] Shutting down Win2K from Perl [In reply to] Can't Post

I guess I'll stay with my current solution - after all it's not something serious...
Thanks for the answer though Smile


Jean Spector
SQA Engineer @ Exanet
jean.spector@softhome.net


There are only 10 types of people in the world -
Those who understand binary, and those who don't.


(This post was edited by Jean on Jul 23, 2002, 4:19 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives