2017-07-03 59 views
0

我正在创建一个执行ftp上传批处理文件的任务。Windows任务计划程序将不会运行ren命令,但是cmd.exe将会

批处理脚本只是将某个文件夹中的任何文件重命名为适当的名称,然后上传该文件夹。

我已经将任务设置为在服务帐户下运行,当我使用服务帐户登录并运行完美的.bat文件时。当我运行任务计划程序时,它运行.bat文件,但日志显示ren命令不起作用。

下面是从日志通过任务调度程序被调用后的输出:

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 

这里是刚刚手动调用.bat文件的输出:

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 

我正在运行的任务具有完全的权限,并且也尝试在与.bat相同的目录中启动它,并且没有,这两个都不起作用。欣赏任何指针/想法。

回答

1

我是,假设R:是映射驱动器。映射驱动器在用户登录时建立,因为它们仅映射给执行映射的用户。该服务帐户不知道任何有关您的帐户下映射的映射驱动器。为了使问题复杂化,根据您的任务设置,任务可以在S4U认证下运行,这样您就无法访问网络资源。这也消除了使用UNC而不是映射驱动器。见technet.microsoft.com/en-us/library/cc722152(v=ws.11).aspx

相关问题