使用 Perl 调用受保护的 Windows 7 可执行文件
我正在尝试编写一个 perl 脚本来确定哪些用户当前使用 query.exe (c:\Windows\system32\query.exe) 登录到 Windows。 Perl 无法访问该文件,无法执行它,甚至无法看到它存在,正如我通过以下代码发现的那样:
print `dir c:\\windows\\system32\\query*`;
这会产生以下输出:
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
我已使用 perl 的 getlogin
函数,它返回本地管理员组成员的名称(特别是我)。我还尝试为“Everyone”添加读取/执行权限,但是当我尝试修改此文件的权限时,Windows 不断给出访问被拒绝的错误。最后,我尝试以管理员身份运行 perl.exe,但这也不能解决问题。
我可以通过更改 Windows 中的某些设置来解决这个问题吗?我需要在我的 perl 脚本中添加一些东西吗?或者是否没有办法授予 perl 访问其中某些进程的权限?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我的 64 位计算机上,我可以在
Windows\System32
(64 位系统目录)中找到query.exe
,但在Windows\SysWOW64
中找不到( 32 位系统目录)。我怀疑您运行的是 64 位 Windows 和 32 位 Perl,因此,在 WOW64 模拟下,32 位 Perl 进程将
system32
重定向到SysWOW64
。由于
system32
应该在您的路径中,因此您应该能够通过执行query.exe
而无需任何路径来执行它。如果您绝对必须引用 64 位系统文件夹,那么您可以使用C:\Windows\sysnative
从 32 位进程执行此操作。如果我的怀疑是正确的,我建议您阅读一下 WOW64,因为在您掌握它之前,它可能会非常令人困惑。另一方面,如果你已经知道这一切,我很抱歉你的居高临下。
On my 64 bit machine I can find
query.exe
inWindows\System32
(the 64 bit system directory) but not inWindows\SysWOW64
(the 32 bit system directory).I suspect that you are running 64 bit Windows and 32 bit Perl and so, under WOW64 emulation, the 32 bit Perl process redirects
system32
toSysWOW64
.Since
system32
should be in your path you ought to be able to execute it by executingquery.exe
without any path. If you absolutely have to refer to the 64 bit system folder then you can do so from a 32 bit process withC:\Windows\sysnative
.If my suspicions are correct I recommend you do some reading up on WOW64 because it can be pretty confusing until you get on top of it. On the other hand, if you already know all about it I apologise for being patronising.