Module: Win32::Certstore::Mixin::ShellExec

Included in:
StoreBase
Defined in:
lib/win32/certstore/mixin/shell_exec.rb

Instance Method Summary collapse

Instance Method Details

#powershell_exec(*command_args) ⇒ Mixlib::Shellout

Run a command under powershell with the same API as shell_out. The options hash is extended to take an “architecture” flag which can be set to :i386 or :x86_64 to force the windows architecture.

Parameters:

  • script (String)

    script to run

  • options (Hash)

    options hash

Returns:

  • (Mixlib::Shellout)

    mixlib-shellout object



42
43
44
45
46
47
# File 'lib/win32/certstore/mixin/shell_exec.rb', line 42

def powershell_exec(*command_args)
  script = command_args.first
  options = command_args.last.is_a?(Hash) ? command_args.last : nil

  run_command_with_os_architecture(script, options)
end

#powershell_exec!(*command_args) ⇒ Mixlib::Shellout

Run a command under powershell with the same API as shell_out! (raises exceptions on errors)

Parameters:

  • script (String)

    script to run

  • options (Hash)

    options hash

Returns:

  • (Mixlib::Shellout)

    mixlib-shellout object



55
56
57
58
59
# File 'lib/win32/certstore/mixin/shell_exec.rb', line 55

def powershell_exec!(*command_args)
  cmd = powershell_exec(*command_args)
  cmd.error!
  cmd
end

#shell_out_command(*command_args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/win32/certstore/mixin/shell_exec.rb', line 24

def shell_out_command(*command_args)
  cmd = Mixlib::ShellOut.new(*command_args)
  cmd.live_stream
  cmd.run_command
  if cmd.error!
    raise Mixlib::ShellOut::ShellCommandFailed, cmd.error!
  end

  cmd
end