Description
User would like to add the option to re-use existing vbscripts to be used for executable facts.
Here is the information from their ticket:
Hi, we like the option to re-use existing vbscripts to be used for executable facts. This is really easy by putting the below in facter/util/parser.rb (mostly a copy of the powershell part). (No we don't want to execute vbscript from batch file just as you don't want that for powershell). Can this functionality be added to the product so the windows agent gets that? Thanks, looking forward to your response.
- Executes and parses the key value output of VBScript/Windows Scripting Format scripts
class VBScriptParser < Base - Returns a hash of facts from vbscript output
def parse_results
cscript =
if File.exists?("# {ENV['SYSTEMROOT']}\\sysnative
cscript.exe")
"#{ENV['SYSTEMROOT']}\\sysnative
{ENV['SYSTEMROOT']}\\system32
cscript.exe"
elsif File.exists?("#
cscript.exe")
"#{ENV['SYSTEMROOT']}\\system32
cscript.exe"
else
'cscript.exe'
end
shell_command = "\"#
{cscript}\" \"#{filename}\""output = Facter::Core::Execution.exec(shell_command)
KeyValuePairOutputFormat.parse(output)
end
end
register(VBScriptParser) do |filename|
Facter::Util::Config.is_windows? && extension_matches?(filename, %w{vbs wsf}) && File.file?(filename)
end
1 line could be a bit better to not show the cscript banner, so add the //NoLogo:
shell_command = "\"#{cscript}
\" //Nologo \"#
{filename}\""