Calling a protected Windows executable with Perl

Posted by Jake on Stack Overflow See other posts from Stack Overflow or by Jake
Published on 2011-02-22T23:21:46Z Indexed on 2011/02/22 23:25 UTC
Read the original article Hit count: 343

Filed under:
|
|

I'm trying to write a perl script that determines which users are currently logged into Windows by using query.exe (c:\Windows\system32\query.exe). Perl is unable to access this file, unable to execute it, even unable to see that it exists, as I've found with the following code:

print `dir c:\\windows\\system32\\query*`;

This produces the following output:

07/13/2009  05:16 PM         1,363,456 Query.dll
1 File(s)      1,363,456 bytes
0 Dir(s)  183,987,658,752 bytes free

I've checked the user executing the script using perl's getlogin function, and it returns the name of a member of the local Administrators group (specifically, me). I've also tried adding read/execute permissions for "Everyone", but windows keeps giving me access denied errors when I try to modify this file's permissions. Finally, I've tried running perl.exe as an administrator but that doesn't fix the problem either.

Is this something I can solve by changing some settings in Windows? Do I need to add something to my perl script? Or is there just no way to grant perl access to some of these processes?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about perl