我正在按照我的 ServiceDefinition.csdef 中的以下内容启动启动脚本
<Startup>
<Task commandLine="Microsoft.WindowsAzure.Caching\ClientPerfCountersInstaller.exe install" executionContext="elevated" taskType="simple" />
<Task commandLine="startup.cmd" executionContext="elevated" taskType="simple" />
</Startup>
startup.cmd 文件是
@echo off
REM StartupLog.txt can be found at (E or F):\approot\bin
Echo Copying MyUtil to system root >> StartupLog.txt 2>&1
copy /y MyUtil.exe %SystemRoot% >> StartupLog.txt 2>&1
IF ERRORLEVEL 1 GOTO ErrorExit
REM It's ok if the next fails, the task may not be scheduled 1st time
Echo Trying to delete MyUtil from scheduler >> StartupLog.txt 2>&1
schtasks /Delete /F /TN "MyUtil" >> StartupLog.txt 2>&1
Echo Adding MyUtil to Scheduler >> StartupLog.txt 2>&1
schtasks /Create /SC MINUTE /MO 2 /SD 11/01/2012 /TN "MyUtil" /TR %SystemRoot%\MyUtil.exe >> StartupLog.txt 2>&1
IF ERRORLEVEL 1 GOTO ErrorExit >> StartupLog.txt 2>&1
GOTO End
:ErrorExit
REM Report the date, time, and ERRORLEVEL of the error.
%ERRORLEVEL% >> StartupLog.txt 2>&1
DATE /T >> StartupLog.txt 2>&1
TIME /T >> StartupLog.txt 2>&1
ECHO An error occurred during startup. ERRORLEVEL = %ERRORLEVEL% >> StartupLog.txt 2>&1
ECHO ----------------------------------------------------------- >> StartupLog.txt 2>&1
EXIT /B 1
:End
ECHO Exiting at end with 0 >> StartupLog.txt 2>&1
ECHO ----------------------------------------------------------- >> StartupLog.txt 2>&1
EXIT /B 0
(E: or F:)\approot\bin 中的错误是:
Copying MyUtil to system root
1 file(s) copied.
Trying to delete MyUtil from scheduler
SUCCESS: The scheduled task "MyUtil" was successfully deleted.
Adding MyUtil to Scheduler
ERROR: No mapping between account names and security IDs was done.
(43,4):LogonType:'1' is not recognized as an internal or external command,
operable program or batch file.
如果我在 RDP 进入 WebRole 之后运行 startup.cmd 文件,那么这些任务就会很好地添加到调度程序中。由于某种原因,它总是无法通过部署。有谁知道如何解决这一问题?我恢复到 OSVersion=2 直到我可以解决这个问题。