我正在尝试做我认为非常简单的事情:拥有一个.bat
重命名网络驱动器上的两个文件夹的文件。从提示符运行时脚本工作正常,但不是从调度程序运行。有什么想法吗?
设定
网络驱动器\\NAS\Backup
映射为B:
Backup
应该重命名文件夹:Current
和Previous
- \\ NAS \备份\当前
- \\ NAS \备份\上一页
任务XML
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2013-12-12T16:01:26.5634611</Date>
<Author>nivis-server\nivis</Author>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2013-12-12T00:00:05</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByWeek>
<DaysOfWeek>
<Saturday />
</DaysOfWeek>
<WeeksInterval>1</WeeksInterval>
</ScheduleByWeek>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>nivis</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\script\SwitchNivisCurrent.bat</Command>
<Arguments>> execution.log</Arguments>
<WorkingDirectory>C:\script</WorkingDirectory>
</Exec>
</Actions>
</Task>
脚本
位于 c:\script
rename B:\Current tmp
rename B:\Previous Current
rename B:\tmp Previous
==========更新:解决方案 - 由techie007提供==========
techie007提供了解决方案,脚本现在看起来像:
net use x: \\10.22.0.105\nivis-nas ****PWD**** /user:nivis
x:
rename Current tmp
rename Previous Current
rename tmp Previous
net use x: /d