Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-768

Add the option to re-use existing vbscripts to be used for executable facts.

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Normal
    • Resolution: Won't Fix
    • None
    • None
    • PE, Windows
    • None
    • Agent

    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.

      1. Executes and parses the key value output of VBScript/Windows Scripting Format scripts
        class VBScriptParser < Base
      2. Returns a hash of facts from vbscript output
        def parse_results
        cscript =
        if File.exists?("# {ENV['SYSTEMROOT']}\\sysnative
        cscript.exe")
        "#{ENV['SYSTEMROOT']}

        \\sysnative
        cscript.exe"
        elsif File.exists?("#

        {ENV['SYSTEMROOT']}\\system32
        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}

      \""

      Attachments

        Activity

          People

            eric.sorenson Eric Sorenson
            tim.purkerson Tim Purkerson
            Eric Thompson Eric Thompson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support