0
votes

I am creating a task that executes a batch file for ftp uploads.

The batch script just renames any file in a certain folder to an appropriate name, then uploads that folder.

I have set the task to run under a service account, when I log in with the service account and run the .bat file it works perfectly. When I run the task scheduler it runs the .bat file but the log shows that the ren command doesn't work.

Here is the output from the log after being invoked via task scheduler:

c:\TEMP\Bulletin>rename "R:\x\x\x\*.pdf" Bulletin.pdf 

c:\TEMP\Bulletin>chdir c:\Program Files (x86)\WinSCP 

c:\Program Files (x86)\WinSCP>WinSCP.com /ini=nul /script=c:\TEMP\Bulletin\bulletin.tmp 
Searching for host...
Connecting to host...
Authenticating...
Using username "svc-bulletin".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] [email protected]
File or folder 'C:\FileShares\Drive-R\x\x\x\Bulletin.pdf' does not exist.
System Error.  Code: 2.

The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort

c:\Program Files (x86)\WinSCP>exit

Here is the output from just manually invoking the .bat file:

C:\TEMP\Bulletin>rename "R:\x\x\x\*.pdf" Bulletin.pdf 

C:\TEMP\Bulletin>chdir c:\Program Files (x86)\WinSCP 

c:\Program Files (x86)\WinSCP>WinSCP.com /ini=nul /script=c:\TEMP\Bulletin\bulletin.tmp 
Searching for host...
Connecting to host...
Authenticating...
Using username "svc-bulletin".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] [email protected]
C:\FileShares\Drive-R\x\x\x\Bulletin.pdf |         957 KB | 1390.5 KB/s | binary | 100%

c:\Program Files (x86)\WinSCP>exit

I am running the task with full permissions and have also tried starting it in the same directory as the .bat and without, neither works. Appreciate any pointers/ideas.

1

1 Answers

1
votes

I'm, assuming R: is a mapped drive. Mapped drives are established when a user logs on as they are only mapped for the user that did the mapping. The service account doesn't know anything about mapped drives that are mapped under your account. To complicate the issue the task may be running under S4U authentication depending on your task settings so you won't have access to network resources. That also eliminates using a UNC rather than a mapped drive. See technet.microsoft.com/en-us/library/cc722152(v=ws.11).aspx