2012-11-11 33 views
2

我踢了每下面的啓動腳本在我ServiceDefinition.csdef中Azure的部署失敗,因爲啓動腳本

<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. 

如果我RDPing到WebRole後運行STARTUP.CMD文件,然後將任務獲得順從調度程序就好了。出於某種原因,它總是通過部署失敗。有誰知道如何解決這一問題?我恢復到OSVersion = 2,直到我可以解決這個問題。

+0

什麼是** ERRORLEVEL **?你應該[輸出到日誌文件'>>「%TEMP%\ StartupLog.txt」'](http://msdn.microsoft.com/en-us/library/windowsazure/hh974418.aspx) – SliverNinja

+1

奇怪的是,沒有任何東西寫入StartupLog.txt。當我的RDP進入機器%TEMP%時是'D:\ Users \ \ AppData \ Local \ Temp \ 2'。我搜索了整個虛擬機「StartupLog.txt」 - 什麼都沒有! – DeepSpace101

回答

0

原因可能是執行腳本的用戶沒有(還)有AppData目錄。你可以嘗試在啓動任務的頂部添加這些嗎?

md "%~dp0appdata" 
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f 
+0

沒有幫助,仍然沒有輸出和腳本仍然失敗。我知道ErrorLevel!= 0,因爲11分鐘的常規部署開啓約1小時。我還升級了OSFamily = 3,因此我們使用Windows(Azure)Server 2012,但問題仍然存在。任何想法啓動腳本運行在哪個帳戶下? RDP用戶?我需要一個更快的方式來觸發啓動腳本exec,而不是完全重新部署來快速調試它... – DeepSpace101

0

我有相同的問題,浪費了幾個小時,以爲這是一個權限問題後,事實證明,它希望指定爲/ TR參數路徑周圍的雙引號。其實我有命令行參數,所以我需要指定它像「\」appname.exe \「\」參數\「」

像你一樣,我在我的任務中使用環境變量 - 這可能是相關的,雖然我不知道爲什麼。和你一樣,當作爲我的RDP用戶啓動時,任務運行良好,但在作爲SYSTEM下的實際啓動任務運行時失敗。

我知道幾個月過去了,所以你可能已經從這個問題上移動了,但我很好奇這些引號是否也爲你解決了問題(對於獎勵點,解釋它爲什麼在意! )。