ActiveState Community

system(...) works for restart but not logoff

Posted by ashwinkraj on 2009-09-09 08:01

The following code for restarting the computer from a CGI script executed via the browser works:

#!C:/perl/bin/perl.exe
system ( "C:/WINDOWS/system32/shutdown.exe", "-r");

But the same code altered to logoff the user does not work:

#!C:/perl/bin/perl.exe
system ( "C:/WINDOWS/system32/shutdown.exe", "-l");

I get the error - "Incorrect Function". From a DOS console, I can restart or logoff the user using the shutdown command and the-r and-l flags respectively.

I am using XAMPP for hosting the CGI file, and using a separate installation of ActivePerl to execute the scripts.

Can some help me with this?

Thanks.

Ashwin