title: Calling a protected Windows 7 executable with Perl
body: <p>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:</p>
  
  <pre><code>print `dir c:\\windows\\system32\\query*`;
  </code></pre>
  
  <p>This produces the following output:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I've checked the user executing the script using perl's <code>getlogin</code> 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.</p>
  
  <p>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?</p>