BoardBabe Posted December 15, 2005 Share Posted December 15, 2005 (edited) AutoIt script to automate Network Setup WizardScript will use information from winnt.sif (read from CDROM\i386\winnt.sif) (looking for TurnOffFirewall and JoinWorkGroup line), apply UserProfile as Computername and automaticly setup windows for file and printer sharing on LAN conencted through a router.The window title and texts are retrieved from Norwegian WinXP and therefore needs to be translated before use at your english or other lang. system, you might also want to change the selection LETTER at connection dialog 1 and 2 to suie your language (Send(e"{ENTER}"), the rest is ready for use at any system.; ----------------------------------------------------------------------------; Script settings; ----------------------------------------------------------------------------#NoTrayIcon#Include <process.au3>#Include <file.au3>AutoItSetOption("WinTitleMatchMode", 4)BlockInput(1); ----------------------------------------------------------------------------; Verify cdrom drive letter; ----------------------------------------------------------------------------; File to look for at CDROM root.$searchfile = "win51ip.SP2"$drvs = DriveGetDrive("CDROM")If Not @error Then For $i = 1 To $drvs[0] If DriveStatus($drvs[$i] & "\") = "READY" Then If FileExists($drvs[$i] & "\" & $searchfile) Then $cdrom = $drvs[$i] Else Exit EndIf EndIf NextEndIf; ----------------------------------------------------------------------------; Retrieve WorkGroup from winnt.sif; ----------------------------------------------------------------------------; Path to winnt.sif on $cdrom.$winntsif = $cdrom & "\I386\winnt.sif"; Open file for reading.$varfile1 = FileOpen($winntsif, 0); Check if file opened for reading OK.If $varfile1 = -1 Then Exit; Read in lines of text until EOF or JoinWorkGroup line is reached.While 1 $rawline = FileReadLine($varfile1) If @error = -1 Then Exit If StringInStr($rawline, "JoinWorkGroup") Then ExitLoopWEnd; Close file.FileClose($varfile1); Process raw JoinWorkGroup line.; Remove any spaces from the string. $nospace = StringReplace($rawline, " ", ""); Remove any "s from the string. $shortline = StringReplace($nospace, '"', ""); Remove JoinWorkGroup= from string. $TrimLeft = StringTrimLeft($shortline, 14); Convert string to UPPERCASE. $WorkGroup = StringUpper($TrimLeft); ----------------------------------------------------------------------------; Retrieve firewall settings from winnt.sif; ----------------------------------------------------------------------------; ReOpen file for new reading.$varfile2 = FileOpen($winntsif, 0); Check if file opened for reading OK.If $varfile2 = -1 Then Exit; Dim firewall variable.dim $firewall; Read in lines of text until EOF or TurnOffFirewall line is reached.While 1 $rawline2 = FileReadLine($varfile2) If @error = -1 Then $firewall = "On" ExitLoop EndIf If StringInStr($rawline2, "TurnOffFirewall") Then $firewall = "Off" ExitLoop EndIfWEnd; Close file.FileClose($varfile2); ----------------------------------------------------------------------------; Convert UserName to valid ComputerName; ----------------------------------------------------------------------------$username = @UserName$insertdash = StringReplace($username, " ", "-")$Computername = StringLeft($insertdash, 15); ----------------------------------------------------------------------------; Launch the Network setup wizard; ----------------------------------------------------------------------------_RunDos(@SystemDir & "\netsetup.cpl"); Welcome dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Velkommen til veiviseren for nettverksinstallasjon")Send("{Enter}"); Before you continue dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Før du fortsetter")Send("{Enter}"); The listed network connections are disconnected dialog (ignore).If WinWaitActive("Veiviser for nettverksinstallasjon", "Nettverkstilkoblingene som er listet opp nedenfor, er koblet fra", 5) ThenControlClick("Veiviser for nettverksinstallasjon", "Nettverkstilkoblingene som er listet opp nedenfor, er koblet fra", "Button1")Send("{ENTER}")EndIf; Wizard has found a shared internet-connection dialog.If WinWaitActive("Veiviser for nettverksinstallasjon", "Veiviseren har funnet en delt Internett-tilkobling", 5) ThenSend("{DOWN}{ENTER}")EndIf; Connection type dialog 1.WinWaitActive("Veiviser for nettverksinstallasjon", "Denne datamaskinen kobler til Internett gjennom en gate")Send("e{ENTER}"); Connection type dialog 2.WinWaitActive("Veiviser for nettverksinstallasjon", "Denne datamaskinen tilhører et nettverk")Send("{ENTER}"); Computer name dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Eksempler: Datamaskinen i stuen eller Lenas datamaskin")Send("{TAB}" & $Computername & "{ENTER}"); WorkGroup name dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Gi navn til nettverket")Send($WorkGroup & "{ENTER}"); Activate file and printer sharing dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Aktivering av fil- og skriverdeling")Send("S{ENTER}"); Confirmation dialog (confirm).WinWait("Veiviser for nettverksinstallasjon", "Er du sikker på at du vil slå på fil- og skriverdeling?")ControlClick("Veiviser for nettverksinstallasjon", "Er du sikker på at du vil slå på fil- og skriverdeling?", "Button1"); The network setup wizard will use the following settings dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Veiviseren bruker følgende innstillinger")Send("{ENTER}"); You have to run the wizard on every machine blabla dialog.WinWaitActive("Veiviser for nettverksinstallasjon", "Du må kjøre veiviseren for nettverksinstallasjon en gang på hver av datamaskinene på nettverket.")Send("F{ENTER}"); Finish wizard dialog.WinWait("Veiviser for nettverksinstallasjon", "Fullfører veiviseren for nettverksinstallasjon")ControlClick("Veiviser for nettverksinstallasjon", "Fullfører veiviseren for nettverksinstallasjon", "Button18"); Click no at reboot dialog if it appears.If WinWait("Endring i systeminnstillinger", "Du må starte maskinen på nytt", 5) ThenControlClick("Endring i systeminnstillinger", "Du må starte maskinen på nytt", "Button2")EndIf; ----------------------------------------------------------------------------; Apply firewall settings; ----------------------------------------------------------------------------; If "TurnOffFirewall" was found in winnt.sif, disable firewall for all devices. If $firewall = "Off" Then _RunDos("netsh firewall set opmode mode=DISABLE")Exit; ----------------------------------------------------------------------------; Script End; ---------------------------------------------------------------------------- Edited December 20, 2005 by BoardBabe Link to comment Share on other sites More sharing options...
Thinkster Posted November 25, 2006 Share Posted November 25, 2006 How about an English Version?? Norweigen does no good here and I don't know any Norweigen's to translate!... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now