I am trying to schedule Task on Task Scheduler, every thing is working fine unless I tick "Run with Highest privileges" or "Run weather user is logged on or not"
As soon as I tick this, scheduler stop triggering my Script.
Script- .Bat file using Power Shell command.
Can any one figure out what went wrong?
Edited- ( Changed file location from drive to network drive)
@Echo Off
:: SDate=DAYMONTHYEAR FORMAT of Systemdate
::set SDate=%date:~7,2%%date:~4,2%%date:~10,4%
::Variable for folder path
for /D %%d in ("\\Server\Schd File\AA\*") do (
for %%a in ("%%d\*.*") do (SET "FPath=%%~dpa"
Set "FName=%%~na" )
)
For /F "Tokens=4-9 Delims=-" %%A In ("%FName%") Do (
Set "Freq=%%B"
Set "ADate=%%F%%E%%D"
)
Set "DFormat=ddMMyyyy"
IF %Freq% == Daily (
For /F UseBackQ %%A In (
`Powershell "([datetime]::ParseExact('%ADate%','%DFormat%',[System.Globalization.CultureInfo]::CurrentCulture)).AddDays(-1).ToString('ddMMyyyy')"`
) Do Set "DateF=%%A"
)
IF %Freq% == Weekly (
For /F UseBackQ %%A In (
`Powershell "([datetime]::ParseExact('%ADate%','%DFormat%', [System.Globalization.CultureInfo]::CurrentCulture)).AddDays(-7).ToString('ddMMyyyy')"`
) Do Set "DateF=%%A"
)
IF %Freq% == Monthly (
For /F UseBackQ %%A In (
`Powershell "([datetime]::ParseExact('%ADate%','%DFormat%', [System.Globalization.CultureInfo]::CurrentCulture)).AddMonths(-1).ToString('MMMyyyy')"`
) Do Set "DateF=%%A"
)
mkdir "%FPath%%Freq%\%DateF%"
move "%FPath%\%FName%.*" "%FPath%%Freq%\%DateF%\"
GoTo :EOF