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:または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.
WebRoleにRDPした後にstartup.cmdファイルを実行すると、タスクはスケジューラーに問題なく追加されます。何らかの理由で、展開によって常に失敗します。誰かがこれを修正する方法を知っていますか?この問題を修正できるまで、OSVersion=2に戻しました。