2

I have the following XML in my .wxs file for running a batch file on uninstall:

<InstallExecuteSequence>
  <Custom Action="uninstall_action" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>

and

<Fragment>
  <CustomAction 
    Id         ="uninstall_action"
    Directory  ="INSTALLDIR"
    ExeCommand ="&quot;[INSTALLDIR]uninstallTester.bat&quot;"
    Execute    ="deferred"
    Impersonate="no"
  />
</Fragment>

So it should run a batch file located in the install directory. My batch file looks like this:

schtasks /Create /F /SC ONCE /ST 22:05 /TN exampleUninstall /TR "echo hello" 2> batch_log.log

When I run the uninstaller I get the following inside the batch_log.log:

ERROR: No mapping between account names and security IDs was done.
(40,4):UserId:

It seems to have a problem specifically only with creating a new scheduled task, because if I change the batch to remove a scheduled task, it runs without error. So my question is: how can I schedule this one time task to run? Also running the batch file by itself will also work, it just has a problem when being called by the uninstaller.

I've also tried googling that specific error with no luck.

I've simplified my actual use case, so I cannot merely just move the schtasks command into the ExecCommand in the installer, it must live inside a batch file (actually it will live inside an executable, but I thought this batch example is easier)

Aaron Harrington
  • 532
  • 3
  • 13
  • 1
    You can try adding /RU "SYSTEM" to your cmd. I've never run schtasks but it might work? It sounds like there's some confusion between user logged into the machine but running the tasks under system context. – Brian Sutherland Aug 23 '16 at 14:51
  • @BrianSutherland That seemed to do the trick. If you post it as an answer I'll accept it. – Aaron Harrington Aug 23 '16 at 23:41

1 Answers1

1

You can try adding /RU "SYSTEM" to your cmd. I've never run schtasks but it might work? It sounds like there's some confusion between user logged into the machine but running the tasks under system context.

Brian Sutherland
  • 4,698
  • 14
  • 16