I have a small VBS script that I want to run once per day.
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
objExcelApp.DisplayAlerts = False
sFilePathXlsm = "C:\Users\$$$$\Desktop\test.xlsm"
Set iWb = objExcelApp.Workbooks.Open(sFilePathXlsm)
sMacroToRun = "'" & sFilePathXlsm & "'!helloworld"
objExcelApp.Run sMacroToRun
iWb.Save
iWb.Close
objExcelApp.DisplayAlerts = True
objExcelApp.Quit
Inside the Windows Task Scheduler I put this for the Program/Script:
"C:\Windows\System32\cscript.exe"
This for the Add Argument:
"C:\Users\$$$$\Desktop\script.vbs"
When I run this with "Run only when user is logged on" it works fine. But if I select "Run whether user is logged on or not", nothing happens and the script does not run.
This script is going to be put inside a VM, so the user may be logged in or not (don't know). So I need to guarantee that this script will run by itself with and without a user logged in.