windows - How do I run a shell command inside a rake task as administrator? -
i have short .cmd file run part of deployment process. unfortunately .cmd file requires administrator privileges. possible administrator permission within rake, or need start shell admin?
you can seek runas command. don't know rake task looks like, if you're running kernel#system, seek
task :foo scheme "runas /profile /user:#{env["computername"]}/administrator mybatchfile.cmd" end only problem is, runas prompts credentials right there in shell. so, you'd have interactive.
irb > scheme "runas ..." come in password foobar/administrator:
there's this nasty looking batch/wsh answer question on so. don't know set command, looks interactive, well.
you might seek powershell start-process cmdlet supports showing uac prompt.
ps> start-process mybatchfile.cmd -verb runas or, in rake
task :foo scheme "powershell -noprofile -noninteractive -executionpolicy bypass -command \"start-process mybatchfile.cmd -verb runas\"" end but launch uac dialog. whole process going need interactive. can't have interactive build script. selection allowing build server run uac off... then, don't have anything, because prompts admin default.
windows shell rake
No comments:
Post a Comment