I would like to achieve this using win32ole
only and not any other way to execute shell commands in ruby.
require 'win32ole'
shell = WIN32OLE.new('Shell.Application')
my_username = shell.ShellExecute('cmd.exe', 'username', '', 'open', 0)
puts my_username
#Current output => nil
Just want to print my username but generally would like to execute any commands and get its output. I know we have ENV['user']
or echo %username%
gives me what I want but want this using win32ole only.
Thanks a lot in advance.