0
我想運行以下腳本作爲客戶自定義的一部分,因此當我從模板部署VM時,Windows卷具有正確的驅動器號。下面的腳本工作,但需要重新啓動,重新啓動後,我想調用我的SQL安裝程序命令,目前只是.cmd文件中的一行。任何人都可以幫助我將一個等待命令添加到驅動器盤符腳本,然後在重新啓動後調用cmd命令嗎?VBS重新啓動並在同一臺服務器上等待
PowerShell還有一個更簡單的方法嗎?
CMD File;
cd c:
C:\Setup\SQL2008R2_SP2\Setup.exe /CONFIGURATIONFILE=C:\Setup\SQL2008R2.ini /INDICATEPROGRESS
Change Drive Letters (Original source http://imallvirtual.com/?p=482)
' Script that changes drive letters
' Note: Do NOT use it on SYSTEM or BOOT partition drive letters !!!
set objShell = CreateObject("WScript.Shell")
' objShell.Run("regedit /s C:\Setup\MsgBox.reg")
sComputer = "."
Const HKLM = &H80000002
' from/to
If ChangeDrvLetter("D:", "T:") Then
End If
If ChangeDrvLetter("F:", "X:") Then
End If
If ChangeDrvLetter("G:", "D:") Then
End If
Function ChangeDrvLetter(sSourceDrive, sTargetDrive)
bOK = True ' Init value
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\default:StdRegProv")
sKeyPath = "SYSTEM\MountedDevices"
sSrc = "\DosDevices\" & UCase(sSourceDrive)
iRC = oReg.GetBinaryValue(HKLM, sKeyPath, sSrc, sValue)
If iRC = 0 Then
sTrg = "\DosDevices\" & UCase(sTargetDrive)
iRC = oReg.SetBinaryValue(HKLM, sKeyPath, sTrg, sValue)
If iRC = 0 Then
oReg.DeleteValue HKLM, sKeyPath, sSrc
Else
bOK = False
End If
Else
bOK = False
End If
ChangeDrvLetter = bOK
End Function
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
感謝您的回覆,我設法通過在'RunOnce'(http://support.microsoft.com/kb)中創建註冊表項來解決此問題/ 310593/zh-cn)然後在重新啓動時調用SQL安裝批處理文件。無論如何,謝謝:) – user2704164
我同意你的意見,Reg-RunOnce aproech要簡單得多。但是,如果需要,Task-scheduler可能會有更多的日誌。 –