I have a PowerShell script - it opens a MS Access database, run a VBA script, and later close itself. It runs greatly manually.
Scheduled user is in the 'Administrator' of the computer and E is a local drive.
However, when I schedule it as a Windows task, it hangs. Codes are below. Could anyone tell me what went wrong?
$Access = New-Object -Com Access.Application
$Access.OpenCurrentDatabase("E:\Audit\audit.accdb")
$Access.Run("fun_run")
$Access.CloseCurrentDatabase()
$Access.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($Access)
Remove-Variable Access