Closed airblade closed 9 years ago
airblade, I finally got around to addressing this in the script… https://gist.github.com/drewreece/1239489
The hosts file now has the line to gain admin access via a UAC prompt…
net session >NUL 2>&1|| powershell Start-Process '%0' -Verb RunAs&& exit /b|| exit /b
I found that on … http://www.sevenforums.com/general-discussion/12936-how-run-batch-file-admin-2.html?s=0c0b169bcd910dc62c1adc18ef279179
Hope it helps, I can't see any better way to 'run as admin' via VirtualBox's additions, it would need to tap into the cleverness that ievms uses when it edits the registry I guess.
You may want to close this - it is beyond the realm of what ievms is intended to do.
@drewreece Fantastic, thank you :-)
For the record I now use the ievms-ruby gem.
Yesterday this script successfully set up VMs for IE9, 10, and 11 for me.
Now I am trying to modify each Windows'
hosts
file programatically. However it seems thatIEUser
/Passw0rd!
does not have permission to copy files toC:\\Windows\\System32\\drivers\\etc\\hosts
:I have also tried executing a bat file which modifies the
hosts
file, again as theIEUser
, but although the command executed successfully thehosts
file was unchanged.Similarly if I go onto the Windows guest OS and double click my
hosts.bat
, a command window flashes up and vanishes but no changes are made tohosts
.But if I right-click on the bat file and choose
Run as administrator
, it does modifyhosts
.So how can I "run as administrator" programatically?
Many thanks in advance.