I made an app that is running with Admin Privileges. To run the app at windows startup I made an SchTasks, but at uninstall I want to remove it. The closest I could get is:
;script used to remove the auto launch scheduled task
!macro customUnInstall
ExpandEnvStrings $0 %COMSPEC%
ExecWait `"$0" /c "SchTasks /Delete /TN task_name /F & pause"`
!macroend
But it returns ERROR: Access is denied.
. This is because the uninstall doesn't have admin priv. What should I do, should I try to make the uninstall to be executed with admin priv? Or there is another way to remove the task?
Another option in my mind is to make the task to delete it self if the executable is not in path.
The electron package.json I am using:
"win": {
"target": [
"nsis"
],
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"include": "installer/windows/uninstall.nsh",
"allowElevation": true,
"deleteAppDataOnUninstall": true
},