Показать полную графическую версию : [решено] Задание переменной %DiskRoot%
CtrlSoft
02-02-2011, 16:07
Нужно экспортировать в AutoIt, командный файл следующего содержания:
@echo off
FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W Y Z) DO IF EXIST %%i:\sources\install.wim SET diskroot=%%i:
start /wait X:\setup.exe /installfrom:%diskroot%\sources\install.wim /unattend:%diskroot%\boot\xmls\en-us.xml
exit
Все должно быть в скрытом режиме.
За ранее спасибо.
$aDrives = DriveGetDrive (http://www.autoitscript.com/autoit3/docs/functions/DriveGetDrive.htm)("ALL")
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aDrives[0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) DriveStatus (http://www.autoitscript.com/autoit3/docs/functions/DriveStatus.htm)($aDrives[$i]) <> "READY" Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
ContinueLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ContinueLoop)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)($aDrives[$i] & ':\sources\install.wim') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
RunWait (http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm)('X:\setup.exe /installfrom:' & $aDrives[$i] & ':\sources\install.wim /unattend:' & $aDrives[$i] & ':\boot\xmls\en-us.xml')
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
CtrlSoft
02-02-2011, 19:07
Creat0R, премного благодарен!
CtrlSoft
03-02-2011, 10:08
Creat0R, странно, не работает... (
не работает »
А так:
$aDrives = DriveGetDrive (http://www.autoitscript.com/autoit3/docs/functions/DriveGetDrive.htm)("ALL")
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aDrives[0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) DriveStatus (http://www.autoitscript.com/autoit3/docs/functions/DriveStatus.htm)($aDrives[$i]) <> "READY" Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
ContinueLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ContinueLoop)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)($aDrives[$i] & '\sources\install.wim') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
RunWait (http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm)('X:\setup.exe /installfrom:' & $aDrives[$i] & '\sources\install.wim /unattend:' & $aDrives[$i] & '\boot\xmls\en-us.xml')
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
?
madmasles
03-02-2011, 10:21
странно, не работает »Попробуйте заменить;...
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)($aDrives[$i] & ':\sources\install.wim') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
;...
;на
;...
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)($aDrives[$i] & '\sources\install.wim') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
;...
PS
А ответ уже есть.
CtrlSoft
03-02-2011, 11:24
Creat0R, madmasles, спасибо. Теперь работает.
Но хотел бы заметить, @echo off
FOR %%i IN (C D E F G H I J K L M N O P Q R S T U V W Y Z) DO IF EXIST %%i:\sources\install.wim SET diskroot=%%i:
start /wait X:\setup.exe /installfrom:%diskroot%\sources\install.wim /unattend:%diskroot%\boot\xmls\en-us.xml
exit
у меня start /wait а потом exit. Все дело в том что данный скрипт я запускал через winpeshl.ini, и если не добавить start /wait, программа установки запустится, но тут же перезагрузится пк.
В вашем же скрипте нужно наверное отказаться от wait: $aDrives = DriveGetDrive("ALL")
For $i = 1 To $aDrives[0]
If DriveStatus($aDrives[$i]) <> "READY" Then
ContinueLoop
EndIf
If FileExists($aDrives[$i] & '\sources\install.wim') Then
Run('X:\setup.exe /installfrom:' & $aDrives[$i] & '\sources\install.wim /unattend:' & $aDrives[$i] & '\boot\xmls\en-us.xml')
EndIf
Next
Дело в том что во время тестирования, если я закрывал окно установки Windows, то запускалось повторная установка, но с ошибкой что не найден файл ответов.
Попробую в WinPE...
CtrlSoft
03-02-2011, 13:34
проверил в WinPE. Работает.
setdiskroot.exe:$aDrives = DriveGetDrive("ALL")
For $i = 1 To $aDrives[0]
If DriveStatus($aDrives[$i]) <> "READY" Then
ContinueLoop
EndIf
If FileExists($aDrives[$i] & '\sources\install.wim') Then
Run('X:\setup.exe /installfrom:' & $aDrives[$i] & '\sources\install.wim /unattend:' & $aDrives[$i] & '\boot\xmls\en-us.xml')
EndIf
Next
winpeshl.ini:[LaunchApp]
AppPath=%SystemRoot%\Scripts\SetDiskRoot.exe
Появился вопрос, что нужно дописать чтобы перед запуском установки, скрипт проверял есть ли требуемый язык в системе а потом запускала установку с нужным языком?
на пример,
1. Создается переменная для привода.
2. Определяется язык
к примеру ищет папку в X:\sources c названием en-US, если найдена - запускается X:\setup /installfrom:%diskroot%\sources\install.wim /unattend:%diskroot%\boot\xmls\en-us.xml
если не найдена - ищет другую папку - ru-RU и запускает команду X:\setup /installfrom:%diskroot%\sources\install.wim /unattend:%diskroot%\boot\xmls\ru-ru.xml
?
спасибо
madmasles
03-02-2011, 15:04
скрипт проверял есть ли требуемый язык в системе »Наверное, можно так попробовать:$aDrives = DriveGetDrive (http://www.autoitscript.com/autoit3/docs/functions/DriveGetDrive.htm)("ALL")
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $aDrives[0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) DriveStatus (http://www.autoitscript.com/autoit3/docs/functions/DriveStatus.htm)($aDrives[$i]) <> "READY" Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
ContinueLoop (http://www.autoitscript.com/autoit3/docs/keywords.htm#ContinueLoop)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) FileExists (http://www.autoitscript.com/autoit3/docs/functions/FileExists.htm)($aDrives[$i] & '\WINDOWS\explorer.exe') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
MsgBox (http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm)(0, StringUpper (http://www.autoitscript.com/autoit3/docs/functions/StringUpper.htm)($aDrives[$i]), StringLeft (http://www.autoitscript.com/autoit3/docs/functions/StringLeft.htm)(FileGetVersion (http://www.autoitscript.com/autoit3/docs/functions/FileGetVersion.htm)($aDrives[$i] & '\WINDOWS\explorer.exe', 'DefaultLangCodepage'), 4))
;0419 русский
;0409 английский
; и т.д.
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
CtrlSoft
02-08-2011, 23:35
потребовалось запустить команду Run с другими параметрами. При этом нужно указать два разных пути, которые требуется определить наличием файлов на диске.
Т.е. переменная №1 - ищем файл в корень диска
переменная №2 - ищем файл из папки в корень диска (\folder\file.wim)
после определения переменных происходит запуск:
%переменная№1%\folder0\folder1\folder2\setup.exe /installfrom:%переменная№2%\folder0\file.wim /unattend:%переменная№1%\folder0\folder1\folder2\file.xml
Язык системы можно определить так:
$UserIntLang=DllCall ("kernel32.dll", "int", "GetUserDefaultUILanguage" )
If Not @error Then MsgBox(0, 'Язык системы', Hex($UserIntLang[0],4))
проверку существования xml можно так
If FileExists($aDrives[$i] & '\boot\xmls\en-us.xml') Then
Run('X:\setup.exe /installfrom:' & $aDrives[$i] & '\sources\install.wim /unattend:' & $aDrives[$i] & '\boot\xmls\en-us.xml')
ElseIf FileExists($aDrives[$i] & '\boot\xmls\ru-ru.xml') Then
Run('X:\setup.exe /installfrom:' & $aDrives[$i] & '\sources\install.wim /unattend:' & $aDrives[$i] & '\boot\xmls\ru-ru.xml')
EndIf
определение переменных можно так:
If FileExists($aDrives[$i] & '\переменная№1') And FileExists($aDrives[$i] & '\переменная№2') Then Run(EnvGet('переменная№1')&'\folder0\folder1\folder2\setup.exe /installfrom:'&EnvGet('переменная№2')&'\folder0\file.wim /unattend:'&EnvGet('переменная№1')&'\folder0\folder1\folder2\file.xml')
Хотя последнее я не понял, даже если файлы указаны, то с какой стати переменные будут существовать в системе? Функция EnvGet берёт значение указанной переменной из системы. Если сам файл переменная, то тогда имя подставлять без EnvGet. Вобщем сомневаюсь в ответе, если вопрос нечёткий.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.
Available in ZeroNet 1osznRoVratMCN3bFoFpR2pSV5c9z6sTC