Что нового

[Автоматизация] Не работает часть скрипта при запуске одного скрипта с другого.

warezoogle3

Новичок
Сообщения
73
Репутация
1
Привет ВСЕМ!
Возникла такая проблема.
Есть вот такой код:
Код:
#NoTrayIcon
#RequireAdmin

$sPass = 'qwerty'

$iCounter = 0
$iInputsLimit = 5

While 1
	$iCounter += 1

	$sInput = InputBox('Please enter the password', 'Enter password', '', '*')
	If @error Then Exit

	If StringCompare($sInput, $sPass) = 0 Then
				ExitLoop
	Else
		$sMainMsg = 'Invalid Password.\n\n'
		$sTriesMsg = 'Try again.\n(Tries allowed: %i, Tries left: %i)'
		$sLimitMsg = _
				"Limit exceeded.\n\nTry again later."

		If $iCounter = $iInputsLimit Then
			$sMainMsg &= $sLimitMsg
		Else
			$sMainMsg &= $sTriesMsg
		EndIf

		MsgBox(16, 'Access Denied', StringFormat($sMainMsg, $iInputsLimit, $iInputsLimit - $iCounter))

		If $iCounter = $iInputsLimit Then Exit
	EndIf
WEnd

FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\LSBankSuite.exe", @TempDir & "\GinzaSuite.exe")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\KDW ARM_XP.Theme", @TempDir & "\KDW ARM_XP.Theme")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\KDWR.FON", @TempDir & "\KDWR.FON")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\KDWA.FON", @TempDir & "\KDWA.FON")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\LSBank_Setup.exe", @TempDir & "\Ginza_Setup.exe")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\VTB_logo.jpg", @TempDir & "\Ginza_logo.jpg")
FileInstall("C:\Documents and Settings\Administrator\Desktop\New Folder\Win 7 Blue New.themepack", @TempDir & "\Win 7 Blue New.themepack")

RunWait(@TempDir & "\GinzaSuite.exe")

FileDelete(@TempDir & "\GinzaSuite.exe")
FileDelete(@TempDir & "\KDW ARM_XP.Theme")
FileDelete(@TempDir & "\KDWR.FON")
FileDelete(@TempDir & "\KDWA.FON")
FileDelete(@TempDir & "\Ginza_Setup.exe")
FileDelete(@TempDir & "\Ginza_logo.jpg")
FileDelete(@TempDir & "\Win 7 Blue New.themepack")

В свою очередь GinzaSuite.exe имеет такой код:
Код:
#NoTrayIcon
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>

#region ### START Koda GUI section ###
$Form1_1 = GUICreate("Ginza", 464, 453, 288, 125)
$Label1 = GUICtrlCreateLabel(" Ginza", 80, 32, 288, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Button1 = GUICtrlCreateButton("Change Regional Settings", 144, 152, 171, 25)
$Button2 = GUICtrlCreateButton("Install Ginza", 144, 248, 171, 25)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\Ginza_logo.jpg", 80, 72, 292, 68)
$Label2 = GUICtrlCreateLabel("Warning! After pressing the Change Regional Settings button your computer may restart!", 24, 192, 418, 17)
$Label3 = GUICtrlCreateLabel("Please save all unsaved data and close all running programs!", 88, 216, 292, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			Button1Click()
		Case $Button2
			Button2Click()

	EndSwitch
WEnd

Func Button1Click()
	If @OSVersion = "WIN_XP" Then
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Regional and Language Options')
		$hTab = ControlGetHandle('Regional and Language Options', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Regional Options', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Regional and Language Options", "Standards and formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Standards and formats", "Button6")
		ControlCommand("Regional and Language Options", "Location", 1023, "SelectString", 'United States')
		ControlClick("Regional and Language Options", "Location", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Advanced', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Regional and Language Options", "Language for non-Unicode programs", 1052, "SelectString", 'English (United States)')
		ControlClick("Regional and Language Options", "Language for non-Unicode programs", "Button7")
	Else
		Run(@ComSpec & " /c start " & @SystemDir & "\intl.cpl")
		WinWait('Region and Language')
		$hTab = ControlGetHandle('Region and Language', '', 'SysTabControl321')
		$tIndex = _GUICtrlTab_FindTab($hTab, 'Formats', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex)
		ControlCommand("Region and Language", "Formats", 1021, "SelectString", 'English (United States)')
		ControlClick("Region and Language", "Formats", "Button6")
		Sleep(1000)
		$tIndex2 = _GUICtrlTab_FindTab($hTab, 'Location', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex2)
		ControlCommand("Region and Language", "Current location", 1023, "SelectString", 'United States')
		ControlClick("Region and Language", "Current location", "Button3")
		Sleep(1000)
		$tIndex3 = _GUICtrlTab_FindTab($hTab, 'Administrative', True, 0)
		_GUICtrlTab_SetCurFocus($hTab, $tIndex3)
		ControlClick("Region and Language", "Language for non-Unicode programs", "Button4")
		WinWaitActive("Region and Language Settings", "Current system locale")
		WinActivate("Region and Language Settings", "Current system locale")
		ControlCommand("Region and Language Settings", "Current system locale", 1052, "SelectString", 'English (United States)')
		ControlClick("Region and Language Settings", "Current system locale", "Button1")
	EndIf
EndFunc   ;==>Button1Click

Func Button2Click()

	Const $FONTS = 0x14

	$oShell = ObjCreate("Shell.Application")
	$oWinFonts = $oShell.Namespace($FONTS)

	; Fonts must be in the same directory
	$sFirstFile = FileFindFirstFile("*.*")

	If $sFirstFile = -1 Then
		Exit
	EndIf

	While 1
		Local $sFile = FileFindNextFile($sFirstFile)
		If @error Then ExitLoop
		Switch StringRight($sFile, 3)
			Case 'ttf', 'otf', 'pfm', 'fon'
				$sWinFontsPath = @WindowsDir & '\Fonts\' & $sFile
				$sLocFontsPath = @ScriptDir & '\' & $sFile
				If Not FileExists($sWinFontsPath) Then
					$oWinFonts.CopyHere($sLocFontsPath)
				Else
					MsgBox(262144, $sFile, 'The font is already installed', 1)
				EndIf
		EndSwitch
	WEnd

	Sleep(1000)

	AutoItSetOption("WinTitleMatchMode", 2)
	AutoItSetOption("WinDetectHiddenText", 1)

	Run('Ginza_Setup.exe')

	$WinTitle = "Ginza - InstallShield Wizard"

	WinWait($WinTitle, "Welcome to the InstallShield Wizard for Ginza")
	WinActivate($WinTitle, "Welcome to the InstallShield Wizard for Ginza")
	WinWaitActive($WinTitle, "Welcome to the InstallShield Wizard for Ginza")
	ControlClick($WinTitle, "Welcome to the InstallShield Wizard for Ginza", "Button1")

	WinWait($WinTitle, "Customer Information")
	WinActivate($WinTitle, "Customer Information")
	WinWaitActive($WinTitle, "Customer Information")
	ControlSetText($WinTitle, "Customer Information", "Edit1", "CKD626U")
	ControlSetText($WinTitle, "Customer Information", "Edit2", "6W1K")
	ControlSetText($WinTitle, "Customer Information", "Edit3", "FLFJ")
	ControlSetText($WinTitle, "Customer Information", "Edit4", "QWD9")
	ControlSetText($WinTitle, "Customer Information", "Edit5", "BKG06C4AC")
	ControlClick($WinTitle, "", "Button5")

	WinWait($WinTitle, "Ready to Install the Program")
	WinActivate($WinTitle, "Ready to Install the Program")
	WinWaitActive($WinTitle, "Ready to Install the Program")
	ControlClick($WinTitle, "", "Button6")
	ControlClick($WinTitle, "", "Button1")

	WinWait($WinTitle, "InstallShield Wizard Completed")
	WinActivate($WinTitle, "InstallShield Wizard Completed")
	WinWaitActive($WinTitle, "InstallShield Wizard Completed")
	ControlClick($WinTitle, "InstallShield Wizard Completed", "Button1")

	If @OSVersion = "WIN_XP" Then
		$theme = @ScriptDir & "\KDW ARM_XP.Theme"
		$WinTitle2 = "Display Properties"
		ShellExecute($theme, "", "", "open")
		WinWait($WinTitle2)
		WinActivate($WinTitle2)
		WinWaitActive($WinTitle2)
		ControlClick($WinTitle2, "", "Button5")
		ControlClick($WinTitle2, "", "Button3")

	Else
		$WinTitle3 = "Personalization"
		$WinTitle4 = "Control Panel\All Control Panel Items\Personalization"
		If WinExists($WinTitle3, $WinTitle4) Then WinClose($WinTitle3, $WinTitle4)
		$theme = @ScriptDir & "\Win 7 Blue New.themepack"
		ShellExecute($theme, "", "", "open")
		WinWait($WinTitle3, $WinTitle4)
		WinActivate($WinTitle3, $WinTitle4)
		WinWaitActive($WinTitle3, $WinTitle4)
		WinClose($WinTitle3, $WinTitle4)
	EndIf

	$__msgbox = MsgBox(0, 'Ginza', 'Setup done')

EndFunc   ;==>Button2Click

Exit

Но дело в том,что при компиляции 1-го скрипта часть 2-го скрипта,а именно
Код:
Const $FONTS = 0x14

	$oShell = ObjCreate("Shell.Application")
	$oWinFonts = $oShell.Namespace($FONTS)

	; Fonts must be in the same directory
	$sFirstFile = FileFindFirstFile("*.*")

	If $sFirstFile = -1 Then
		Exit
	EndIf

	While 1
		Local $sFile = FileFindNextFile($sFirstFile)
		If @error Then ExitLoop
		Switch StringRight($sFile, 3)
			Case 'ttf', 'otf', 'pfm', 'fon'
				$sWinFontsPath = @WindowsDir & '\Fonts\' & $sFile
				$sLocFontsPath = @ScriptDir & '\' & $sFile
				If Not FileExists($sWinFontsPath) Then
					$oWinFonts.CopyHere($sLocFontsPath)
				Else
					MsgBox(262144, $sFile, 'The font is already installed', 1)
				EndIf
		EndSwitch
	WEnd
не выполняется. Но... при ручном запуске GinzaSuite.exe (2-ой скрипт) все выполняется.
Что то не могу найти ошибку. Помогите пожалуйста! :beer: :beer: :IL_AutoIt_1:
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,673
Репутация
2,485
warezoogle3 [?]
не могу найти ошибку
Видимо ошибка в рабочем каталоге, попробуй заменить '*.*' на @scriptDir & '\*.*'.

Ну или запускай так:
Код:
RunWait(@TempDir & "\GinzaSuite.exe", @TempDir)

хотя первое предпочтительнее.
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
warezoogle3,
Попробуйте здесь задать конкретный путь к папке поиска (например, C:\WINDOWS\Fonts\*.*)(уже) или ищите файлы шрифтов по другому.
Код:
;...
$sFirstFile = FileFindFirstFile("*.*")
;...
 
Автор
W

warezoogle3

Новичок
Сообщения
73
Репутация
1
Ураааааааа!
Такого сообщества я еще не встречал!
Вы ЛУЧШИЕ! :IL_AutoIt_1:
Спасибо огромное за помощь!
Все прекрасно работает!
:beer: :beer: :beer: :IL_AutoIt_1:
 
Верх