class Inspec::Resources::VBScript

@see msdn.microsoft.com/en-us/library/aa364991.aspx<br>after we executed it
Since Windows does not delete tmp files automatically, we remove the VBScript
version information.
We run cscript with /nologo option to get the expected output only with the
encodedCommand since train does not allow file upload yet.
embedded in Powershell to ease the file transfer and reuse powershell
For that reason, we call csript.exe directy with the script. Vbscript is
$script.ExecuteStatement($Cmd)
$script.language = “vbscript”
$script = new-object -comobject MSScriptControl.ScriptControl
not to use scriptcontrol, due to the fact that it works on 32 bit systems only:
This resource allows users to run vbscript on windows machines. We decided

def initialize(vbscript)

def initialize(vbscript)
  @seperator = SecureRandom.uuid
  cmd = <<~EOH
    $vbscript = @"
    #{vbscript}
    Wscript.Stdout.Write "#{@seperator}"
    "@
    $filename = [System.IO.Path]::GetTempFileName() + ".vbs"
    New-Item $filename -type file -force -value $vbscript | Out-Null
    cscript.exe /nologo $filename
    Remove-Item $filename | Out-Null
  EOH
  super(cmd)
end

def parse_stdout

def parse_stdout
  res = inspec.backend.run_command(@command)
  parsed_result = res.stdout.gsub(/#{@seperator}\r\n$/, '')
  res.stdout = parsed_result
  res
end

def result

def result
  @result ||= parse_stdout
end

def to_s

def to_s
  'Windows VBScript'
end