Windows 7 是否对 Ruby 隐藏文件? [英] Does Windows 7 hide files from Ruby?

查看:30
本文介绍了Windows 7 是否对 Ruby 隐藏文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 ruby​​ 脚本运行程序 nbtstat.exe(位于 c:\windows\system32).问题是 Windows 7(64 位)似乎正在从 ruby​​ 脚本中隐藏该程序(它在 Vista 中运行良好).

I am trying to run the program nbtstat.exe(located in c:\windows\system32) from a ruby script. The problem is that it appears that Windows 7(64-bit) is hiding the program from the ruby script(it works fine in Vista).

例如

Nbtstat 命令:"nbtstat"
dir 命令:dir "C:\Windows\System32\n*.exe"

Nbtstat command: "nbtstat"
Dir command: dir "C:\Windows\System32\n*.exe"

如果我只在命令行中运行 nbtstat 命令,nbtstat 将运行良好.如果我然后运行 ​​dir 命令,nbtstat.exe 将显示在该目录中的文件列表中.

If I run the nbtstat command in just the command line, nbtstat will run fine. If I then run the dir command, nbtstat.exe will show up in the list of files in that directory.

但是,如果我从 ruby​​ 脚本(使用反引号、系统、%x 或 Kernel.open)运行 nbtstat 命令,它将不会成功.如果我然后运行 ​​dir 命令(也来自 ruby​​ 脚本),它将显示目录中的文件列表,减去 nbtstat.exe 和其他一些.

However, if I run the nbtstat command from the ruby script(using backticks, system, %x or Kernel.open), it will not succeed. If I then run the dir command(also from the ruby script), it will show a list of files in the directory minus nbtstat.exe and a few others.

UAC 已关闭,并由管理员运行.我在 ruby​​ 1.8.6 和 1.9.2 中都试过了.

UAC is turned off and it is being ran from an administrator. I tried this in both ruby 1.8.6 and 1.9.2.

我创建了一个运行 nbtstat 命令的 .bat 文件,它运行良好,但如果我从 ruby​​ 脚本调用 .bat 文件,它将失败.

I created a .bat file that runs the nbtstat command and it worked fine but if I call the .bat file from the ruby script it will fail.

有什么想法吗?

谢谢.

推荐答案

在 Win64 上,如果您运行 32 位进程,Windows 将重新映射 c:\windows\system32 目录以实际指向 c:\windows\syswow64.该目录不包含您要查找的二进制文件,因此您的 32 位进程看不到它.

On Win64, if you run a 32-bit process, Windows will remap the c:\windows\system32 directory to actually point to c:\windows\syswow64. That directory doesn't contain the binary you're looking for, so your 32-bit process doesn't see it.

您可以通过查看进程的环境来检测是否是这种情况(查看 env 变量的set"的输出),尽管我不知道有什么方法可以让进程看到实际的 64 位目录.

You can detect whether that's the case by looking at the process's environment (look at the output of "set" for the env variables), although I don't know of a way to make the process see the actual 64-bit directory.

这篇关于Windows 7 是否对 Ruby 隐藏文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆