I have a script that creates a text file on a network drive using VBScript, run as a scheduled task. It is failing now with a "permission denied" error (error 70) but only when run as a scheduled task. If I run it from a logged-in Remote Desktop session on the server with the same user, it runs fine. I have fiddled with the scheduled task settings to turn on "run with highest privileges". If I turn on "run only when user is logged on" it works too. I am puzzled because the line it fails on is the file creation line. Here is the relevant line from the VBS file:
set objWriteFile = objFSO.OpenTextFile(sTargetFile, forWriting, True)
sTargetFile is a UNC path.
I am invoking the .VBS file from a batch file using this command:
c:\windows\system32\cscript.exe //H:cscript //nologo The odd thing is that this worked until Friday. I am not sure if a patch was applied to the server or not. The server hosting this scheduled task is running Windows Server 2008 R2 Standard, SP1. The account is in the Local Administrators group on this server.