hosts - Open the file with admin privilege in ruby -
hosts - Open the file with admin privilege in ruby -
on windows machine(with windows 7 running, x86-64) possible open 'etc/hosts' file in system32/drivers/etc, modify , save ruby?
i "not opened writing(ioerror)" error code simple file = file.open("c:/windows/system32/drivers/etc/hosts") file << "new line"
instead of trying acquire privileges code ( maybe won't portable across different windows os'es ), this:
open command prompt administrator run script thereby doing this, programs you're executing have administrative privileges well.
edit: problem:
file = file.open("c:/windows/system32/drivers/etc/hosts","w") file << "new line"
you have open file in write mode.
ruby hosts
Comments
Post a Comment