Organizational Research By

Surprising Reserch Topic

execute basic windows commands using -'ruby'

execute basic windows commands  using -'ruby'

I would like to achieve this using win32ole only and not any other way to execute shell commands in ruby.

require 'win32ole'
shell ='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.

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.