|
When using the winform program to obtain the cmd command prompt, if it is an operating system above win7, it will need to be run as an administrator to execute successfully, otherwise there will be no effect or error prompt. For example, when executing the cmd command through the winform program, in some cases, if you are not running as an administrator, the command will be invalid. Or when executing a Windows Service service through the winform program, you also need to call the Service service as an administrator. Here's how to make the program run with administrator rights. One: In Visual Studio - Solution Explorer - Right click on the project name - Properties, find the "Security" option, 2: Check "Enable ClickOnce security settings", Three: At this time, there will be an additional "app.manifest" file under the project, select it, find the code snippet, and change it to: , Open it: Modified the above diagram to read: Four: After correction, do not rush to recompile and generate, open the "Properties - Security" interface again, Remove the checkmark in front of "Enable ClickOnce security settings" before compiling and running. Otherwise, the program will report an error and cannot run.
5: Finally, save the modifications and recompile the running program. When you open the program, you will be prompted to "User Account Control" to get administrator privileges to run, and click "Yes" to obtain admin rights.
|