I'm attempting to use MsDeploy runCommand provider to uninstall and reinstall a Windows service during an automated deployment.
So far, I've been somewhat successful when following the advice开发者_如何学运维 in this question and this blog post.
To perform the actual install/uninstall operations, I'm calling a batch file on the remote host. The batch file works as expected when I log into the host directly and use the 'Run as Administrator' option from the shell. When simply running the batch file by double-clicking (or when running the batch file with the MsDeploy runCommand provider), the batch file doesn't have sufficient permissions to perform the install or uninstall operation. In all cases, I'm running the batch file with a user account that is a local administrator on the host.
I've confirmed that runCommand is using an administrator account through the Management Service Delegation tool, and restarted the Management Service just for the heck of it.
My questions know are:
1) How can I emulate the 'Run As Administrator' with the runCommand provider?
2) If I use a Powershell script instead of a batch file, would this still be a problem?
3) Is there something basic I'm missing here?
I would really not have to write real software to perform this action on the remote host!
Any advice would be appreciated.
Have you tried the runas
MSDOS command?
runas /user:mycomputer\myusername somecommand
精彩评论