I have a .Net 4.0 Windows application which requires ac开发者_Go百科cess thru the firewall. I know about the netsh advfirewall firewall command, but I would like very much to have this program allowed at install time (the Click Once deployment).
How can I add this command to execute as a post install command, exectuing as Administrator - i.e. The person doing the install does not have to execute the netsh advfirewall command separately or does not have to go to the Firewall and manually add the program in the Allowed list.
I cannot find an area in Publish in Visual Studio 2010 to insert a post install command line execution.
You can't have a post-install command. If you want to execute a command you'll need to do it from your application after it starts...
if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
//run something
}
There's no way you can force this to run as an Admin. It will run with the same privileges the user has.
精彩评论