I am trying to run a vb script using task scheduler. I am using the .GetAbsolutePathName(".") to get the full path of the script. When I run the script manually, it was able to get the correct path. But when run as scheduled task, it outputs "C:\Windows\System32\ as the path.
I am using the path name to get the full path of an Excel file that I would like to run. The excel file is saved within the same path as the script.
Below is my code:
Set fso = CreateObject("Scripting.FileSystemObject")
scurDir = fso.GetAbsolutePathName(".")
set fso = nothing
Set myxlApplication = CreateObject("Excel.Application")
wscript.echo scurDir & "\OOO Automation Tool.xlsm"
Set myWorkBook = myxlApplication.Workbooks.Open( scurDir & "\OOO Automation Tool.xlsm" )
myxlApplication.Visible = False
myxlApplication.Wait(Now + TimeValue("0:00:10"))
'Run routine
myWorkBook.Application.Run "MOutofOffice.pDetectIdleTime"
'Close application
myxlApplication.Quit
'Release objects
set myxlApplication = nothing
set myWorkBook = nothing
Can you help me get the correct path?