我有一个使用 Windows 7 任务管理器启动的脚本。任务管理器配置为不依赖于我的登录状态(登录/注销)来启动。
在脚本的某个时刻我调用
net start > foo.log
如果我已登录,foo.log 文件不为空。如果我未登录,foo.log 的大小为零,并且出现错误:
Error 5: Access is denied.
是命令净启动取决于我的日志记录状态?
如果是,我该如何开始净启动虽然我还没有登录?
附加信息 这是我的任务设置的导出
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2015-01-08T07:30:09.6060087</Date>
<Author>Jone Doe</Author>
<Description>NightlyBuild</Description>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2015-01-09T22:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>Jone Doe</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</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>boo.bat</Command>
</Exec>
答案1
解决方案是设置高优先级。