Sign in to follow this  
Followers 0
scfunk2002

Help with a script

4 posts in this topic

New to autoit....hacking and slashing a script together to install ie8 under current user, reboot and auto login using a different admin account...to finish installation.....then waiting a few minutes for install to complete and restarting and clearing auto login....thanks to all who posted code....

Not sure why its not working....any assistance would be great.....i am stuck

THANKS

#region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Compression=4

#AutoIt3Wrapper_Res_Fileversion=0.0.0.0

#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y

#AutoIt3Wrapper_Res_Language=1033

#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y

#AutoIt3Wrapper_Run_Tidy=y

#AutoIt3Wrapper_Run_Obfuscator=y

#Obfuscator_Parameters=/striponly

#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

Opt("MustDeclareVars", 1)

Opt("TrayAutoPause", 0)

Opt("TrayMenuMode", 0)

Opt("TrayIconHide", 0)

Global Const $MyName = StringLeft(@ScriptName, StringInStr(@ScriptName, ".", 0, -1) - 1)

Global Const $MyMutex = $MyName & "-4C4FE209743F270A"

Global Const $MyVersion = FileGetVersion(@ScriptFullPath)

If _MutexExists($MyMutex) Then Exit

Global Const $CompanyName = "MyCompany"

Global Const $LogFileName = "c:\" & $MyName & ".log"

Global Const $UseAutoLogin = True

Global Const $mydomain = "@ComputerName"

Global Const $myusername = "username"

Global Const $mypassword = "password"

Global Const $LegalNoticeCaption = "Legal Notice"

Global Const $LegalNoticeText = "This is my legal notice text"

Global Const $DefaultDomain = "mydomain"

Global $lastver = RegRead("HKEY_LOCAL_MACHINE\Software\" & $CompanyName, $MyName & "Version")

If @error Then $lastver = "0.0.0.0"

If _VersionCompare($MyVersion, $lastver) = 1 Then

RegWrite("HKEY_LOCAL_MACHINE\Software\" & $CompanyName, $MyName & "Version", "REG_SZ", $MyVersion)

RegWrite("HKEY_LOCAL_MACHINE\Software\" & $CompanyName, $MyName & "Stage", "REG_DWORD", 0)

EndIf

If @Compiled Then

FileWrite($LogFileName, $CompanyName & " " & $MyName)

FileWriteLine($LogFileName, " - " & @YEAR & "." & @MON & "." & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC)

Else

_DebugSetup($CompanyName & " " & $MyName & " - Status")

EndIf

Global $stage = RegRead("HKEY_LOCAL_MACHINE\Software\" & $CompanyName, $MyName & "Stage")

If @error Then $stage = 0

_SetAutoLogin()

While True

Switch $stage

Case 0

_Status("Installing IE8")

_IE8INSTALL

Case 1

_Status("Finalizing Installation")

Sleep(150000)

Case Else

_2()

_Status("Done")

_ClearAutoLogin()

Shutdown(2 + 16)

Exit

EndSwitch

_NextStage()

WEnd

Func _IE8INSTALL()

RunWait("c:\IE8-WindowsXP-x86-ENU.exe /quiet /update-no /forcerestart")

MsgBox(0, "IE8 Installing")

EndFunc

Func _2()

If FileExists("C:\ie8install.txt") Then Return

MsgBox(0, "Finalizing Install of IE 8 - Please WAIT!")

Shutdown(2)

Exit

EndFunc

Func _NextStage()

$stage += 1

RegWrite("HKEY_LOCAL_MACHINE\Software\" & $CompanyName, $MyName & "Stage", "REG_DWORD", $stage)

EndFunc

Func _SetAutoLogin()

FileCreateShortcut(@ScriptFullPath, @StartupCommonDir & "\" & $MyName & ".lnk", @ScriptDir)

If $UseAutoLogin Then

_Status("Setting auto login")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "Userinit", "REG_SZ", "C:\WINDOWS\system32\userinit.exe,")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "Shell", "REG_SZ", "explorer.exe")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "REG_SZ", $mydomain)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", $myusername)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword", "REG_SZ", $mypassword)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon", "REG_SZ", "1")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText")

EndIf

EndFunc ;==>_SetAutoLogin

Func _ClearAutoLogin()

FileDelete(@StartupCommonDir & "\" & $MyName & ".lnk")

If $UseAutoLogin Then

_Status("Clearing auto login")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName", "REG_SZ", $DefaultDomain)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultUserName", "REG_SZ", "")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "REG_SZ", $LegalNoticeCaption)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText", "REG_SZ", $LegalNoticeText)

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultPassword")

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "AutoAdminLogon")

EndIf

EndFunc ;==>_ClearAutoLogin

Func _Status($msg)

If @Compiled Then

SplashTextOn($CompanyName & " " & $MyName & " - Status", "Stage " & $stage & ": " & $msg, 500, 100, -1, -1, 2 + 16 + 32)

FileWriteLine($LogFileName, "Stage " & $stage & ": " & $msg)

Else

_DebugOut("Stage " & $stage & ": " & $msg)

EndIf

EndFunc ;==>_Status

Func _MutexExists($sOccurenceName)

Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError

$sOccurenceName = StringReplace($sOccurenceName, "\", "")

$handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $sOccurenceName)

$lastError = DllCall("kernel32.dll", "int", "GetLastError")

Return $lastError[0] = $ERROR_ALREADY_EXISTS

EndFunc ;==>_MutexExists

Share this post


Link to post
Share on other sites



First, please use [ autoit] [ /autoit] code tags when posting a script.

Second, what's not working and how is it failing, or what is it doing that it shouldn't be doing according to what you expect it to do? Not working is very vague and not at all helpful as I doubt many people will want to run the script without some inkling as to what to look for.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

If user is not an admin you're not going to get those writes to the HKLM.

Share this post


Link to post
Share on other sites

ok....I have this much working.....

I am sending the package to the machine using altiris......its installing and on reboot....its filling in the correct information.....but...its waiting for a enter button to be pressed to continue with the auto login. Its basically working except for the auto login......key press.......it seems like its not removing the legal notice and maybe thats the hold up?

I need to be able to push this to machine.....install the software....have it reboot and log back in without user intervention or keypress....then change the settings back......and reboot....

___________________________________

Global Const $CompanyName = "Company"

Global Const $UseAutoLogin = True

Global Const $mydomain = "@ComputerName"

Global Const $myusername = "Username"

Global Const $mypassword = "password"

Global Const $LegalNoticeCaption = "Legal Notice"

Global Const $LegalNoticeText = "This is my legal notice text"

Global Const $DefaultDomain = "mydomain"

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "Userinit", "REG_SZ", "C:\Windows\System32\userinit.exe,")

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "Shell", "REG_SZ", "explorer.exe")

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "DefaultDomainName", "REG_SZ", $mydomain)

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "DefaultUserName", "REG_SZ", $myusername)

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "DefaultPassword", "REG_SZ", $mypassword)

RegWrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "AutoAdminLogon", "REG_SZ", "1")

RegDelete("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "LegalNoticeCaption")

RegDelete("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon", "LegalNoticeText")

RunWait("c:IE8-WindowsXP-x86-ENU.exe /quiet /update-no /forcerestart")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0