我有以下片段,我试图用来验证注册表项(操作系统是Windows 2008R2或Win7)
def value_exists?(path,key)
reg_type = Win32::Registry::KEY_READ
Win32::Registry::HKEY_LOCAL_MACHINE.open(path, reg_type) do |reg|
begin
regkey = reg[key]
return true
rescue
return false
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我执行以下2个命令时,输出是预期的(在我的情况下返回false):
puts(value_exists?("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\",'PendingFileRenameOperations'))
puts(value_exists?("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\",'RebootPending'))
Run Code Online (Sandbox Code Playgroud)
当我表演时
puts(value_exists?("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\",'RebootRequired'))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
C:/Ruby187/lib/ruby/1.8/win32/registry.rb:528:in `open': The system cannot find the file specified. (Win32::Registry::Error)
from C:/Ruby187/lib/ruby/1.8/win32/registry.rb:608:in `open'
from ./reg2.rb:7:in `value_exists?'
from ./reg2.rb:21
Run Code Online (Sandbox Code Playgroud)
我真的不明白该怎么做才能做到这一点.我怀疑它可能与x64系统有关,而且无法在正确的位置找到密钥.但我不确定我需要做些什么才能解决这个问题.
感谢您的帮助!
我在JENKINS-44085中发现了这条带有以下代码的消息。
如果我已经有一个包含 50 个项目的分支图,但我想一次并行 5 个项目,我需要如何修改此代码?我的代码已经在名为branches 的 var 中包含了 50 个项目的映射。
// put a number of items into the queue to allow that number of branches to run
for (int i=0;i<MAX_CONCURRENT;i++) {
latch.offer("$i")
}
for (int i=0; i < 500; i++) {
def name = "$i"
branches[name] = {
def thing = null
// this will not allow proceeding until there is something in the queue.
waitUntil {
thing = latch.pollFirst();
return thing != null;
}
try {
echo …Run Code Online (Sandbox Code Playgroud)