Catatan

Tunjukkan catatan dari November, 2021

Force Execute File to Run As Administrator

Imej
Right-click your WPF project to add new Item: "Add->New Item..." Select "Application Manifest File" and click Add Double Click your newly created manifest file and change the <requestedExecutionLevel level="asInvoker" uiAccess="false" /> to <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> Then the WPF application would run as Administrator. References link:  https://stackoverflow.com/a/53431997

How to make Windows Service start as "Automatic (Delayed Start)" ?

  Now that .NET 4.0 is here: serviceInstaller1.StartType = ServiceStartMode.Automatic; serviceInstaller1.DelayedAutoStart = true ; https://stackoverflow.com/a/9525289

Stop and Start a service via batch or cmd file?

  net start [serviceName] and net stop [serviceName] tell you whether they have succeeded or failed pretty clearly. For example U:\>net stop alerter The Alerter service is not started. More help is available by typing NET HELPMSG 3521. If running from a batch file, you have access to the ERRORLEVEL of the return code. 0 indicates success. Anything higher indicates failure. As a bat file,  error.bat : @echo off net stop alerter if ERRORLEVEL 1 goto error exit :error echo There was a problem pause The output looks like this: U:\>error.bat The Alerter service is not started. More help is available by typing NET HELPMSG 3521. There was a problem Press any key to continue . . . Return Codes - 0 = Success - 1 = Not Supported - 2 = Access Denied - 3 = Dependent Services Running - 4 = Invalid Service Control - 5 = Service Cannot Accept Control - 6 = Service Not Active - 7 = Service Request Timeout - 8 = Unknown Failure - 9 = Path Not Found - 10 = Service Already Running -

How to run a ".bat" file during installation?

  62 Well, after much searching and trial and error I have solved this. I'm not sure if this is the best way, but it works. Here's the scenario: I have an application I would like to deploy via a Visual Studio Setup project. In addition to my application files, I would like to create a subdirectory in the target directory that contains a batch (.bat) file. I would like this file to run at the end of the installation process. Here's what you do: Create a setup project and configure as you normally would, including the subdirectory in which you'll place your batch file (you can just place it in the Application Folder directly if you don't want it in a subdirectory). In the "File System" view (right-click on the project in Solution Explorer->View->File System), add the batch file you want to execute  and  cmd.exe (C:\Windows\System32\cmd.exe) Open the "Custom Actions" view (right-click on the project in Solution Explorer->View->Custom Ac