Why does my scheduled task sit queued until the first time someone logs in?

i8displaynames 6 Reputation points
2022-11-09T16:15:18.657+00:00

I am having a problem getting Avid Pro Tools to install using Configuration Manager. The software install fails when run by the system user but works fine for other admin accounts. To get round this I tried running the install using impersonation only to find the the system user isn't allowed to do this. My next plan was to create a scheduled task, which runs as a specified user and initiate it using a script. This seems to work but for some reason when deploying to a new computer the task sits queued until the first time someone logs in. This is the script I am using

$taskname = "install protools"

$user = "tempadmin"

$password = "tempadminpass1"

$securepassword = ConvertTo-SecureString "$password" -AsPlainText -Force

New-LocalUser "$user" -Password $securepassword -FullName "$user" -Description "Temporary local admin"

Add-LocalGroupMember -Group "Administrators" -Member "$user"

$command = "setup.exe"

$arguments = '/S /v"/qn /norestart"'

$StartIn = pwd

$action = New-ScheduledTaskAction -Execute $command -argument $arguments -WorkingDirectory $startin

Register-ScheduledTask -TaskName $taskname -User $User -password $password -Action $action

Start-ScheduledTask -TaskName $taskname

while ((Get-ScheduledTask -TaskName $taskname).State -ne 'Ready') {}

Unregister-ScheduledTask -TaskName $taskname -Confirm:$false

Remove-LocalUser -Name "$user"

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,603 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. MotoX80 31,571 Reputation points
    2022-11-10T01:42:36.547+00:00

    The software install fails when run by the system user but works fine for other admin accounts.

    You should be able to create a log file with the command line switches. Do that and look for errors. Have you contacted Avid Pro Tools support to ask about running as the system account?

    To get round this I tried running the install using impersonation only to find that the system user isn't allowed to do this.

    I would expect that the system account can do anything. What error do you get?

    This seems to work but for some reason when deploying to a new computer the task sits queued until the first time someone logs in.

    Your script issues a Start-Scheduledtask for it. Did the start fail? Did you review the task scheduler event logs? Add a Start-Transcript to the script to generate a Powershell log.

    1 person found this answer helpful.

  2. i8displaynames 6 Reputation points
    2022-11-11T23:36:37.3+00:00

    My task runs if i am logged in or not, but not if no one has ever logged in. Had you ever logged into your vm before creating and running the task?

    1 person found this answer helpful.

  3. MotoX80 31,571 Reputation points
    2022-11-10T13:38:52.957+00:00

    It sounds like you either have a copy of the task still running, or an instance of setup.exe still running (hung?). Look in task manager for setup.exe and kill it. Or just reboot. (Update: the more that I think about this, a reboot would be a good idea.)

    If you look in the software's documentation or run "setup /?" do you see any option to "install for all users", or "install just for this user"? The vendor may have changed how it installs.

    It worked fine with the previous version

    Then based on that comment, I would think that the next best step would be to contact the software vendor and send them the full install log and ask them why their software won't install. You may need to add another command line switch to generate verbose logging to get additional details.

    0 comments No comments

  4. i8displaynames 6 Reputation points
    2022-11-11T10:29:59.4+00:00

    Having turned off verbose login (way too much info) I manage to find the reason the system user install fails

    InstallShield 09:29:48: ResolveSidForAccountName: looking up account name 'DOMAIN\SYSTEM'
    InstallShield 09:29:48: Failed to lookup account name, last error: 0x00000534

    This Should say

    InstallShield 09:29:48: ResolveSidForAccountName: looking up account name 'NT Authority\SYSTEM'

    Seems this is issue affects other software too

    https://www.ibm.com/support/pages/installation-flow-manager-client-silent-mode


  5. MotoX80 31,571 Reputation points
    2022-11-11T16:40:42.613+00:00

    I don't know.

    Here is the script that I tested with. I used invoke-command to get from my laptop to my test VM. The task runs cmd.exe which executes whoami.exe and I redirect the output to a log file.

    Note that I delete any existing task first. That way I can query the task history after I run the test and when I log on to the Win10 VM.

     cls  
     $script =   
     {  
        "This script is running on {0}" -f $env:COMPUTERNAME  
        ""  
        "Deleting the log file"  
        Remove-Item -Path c:\temp\whoami.log  
        ""  
        "Remove the task from the prior test."  
        $taskname = "install protools"  
        Unregister-ScheduledTask -TaskName $taskname -confirm:$false  
        "Now build the task."   
        $user = "tempadmin"  
        $password = "tempadminpass1"  
        $securepassword = ConvertTo-SecureString "$password" -AsPlainText -Force  
        New-LocalUser "$user" -Password $securepassword -FullName "$user" -Description "Temporary local admin"  
        Add-LocalGroupMember -Group "Administrators" -Member "$user"  
        $command = "cmd.exe"  
        $arguments = '/c "whoami.exe " >> c:\temp\whoami.log'  
        $StartIn = pwd  
        $action = New-ScheduledTaskAction -Execute $command -argument $arguments -WorkingDirectory $startin  
        $task = Register-ScheduledTask -TaskName $taskname -User $User -password $password -Action $action  
        Start-ScheduledTask -TaskName $taskname  
        $count = 0  
        while ($count -lt 10) {  
            "State is {0}" -f (Get-ScheduledTask -TaskName $taskname).State  
            if ((Get-ScheduledTask -TaskName $taskname).State -eq 'Ready') {  
                $count = 99  
                "State is ready. Now read the log."  
                Get-Content c:\temp\whoami.log        
            } else {   
                start-sleep -Seconds 5  
            }   
        }   
        "Cleanup and exit."   
        Remove-LocalUser -Name "$user"  
     }  
     $User = ".\admin"  
     $PWord = ConvertTo-SecureString -String "admin" -AsPlainText -Force  
     $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord  
     Invoke-Command -ComputerName "test10" -credential $Credential -ScriptBlock $script   
      
    

    The task runs fine whether I am logged in or not.

    This script is running on TEST10  
      
    Deleting the log file  
      
    Remove the task from the prior test.  
    Now build the task.  
      
    Name      Enabled Description           PSComputerName  
    ----      ------- -----------           --------------  
    tempadmin True    Temporary local admin test10          
    State is Running  
    State is ready. Now read the log.  
    test10\tempadmin  
    Cleanup and exit.  
    
    0 comments No comments