Search code examples
rubywindowscommand-linejruby

System call in JRuby as an administrator


I'm sending a command to the command prompt (in JRuby script) with:

system("cd .. && REG ADD \"HKLM\\SOFTWARE\\etc\\foo\\foo\" /f /v Data /t REG_SZ /d 3")

However, I need administrative rights to execute that command. If I have administrative rights on my machine, how can I tell the command prompt that through this system call?


Solution

  • well have you tried doing a "sudo" with runas e.g. runas /noprofile /user:Administrator

    system("runas /noprofile /user:Administrator REG ADD \"HKLM\\SOFTWARE\\etc\\foo\\foo\" /f /v Data /t REG_SZ /d 3")
    

    for more please see https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows