Sign in to follow this  
Followers 0
SilentCurse

[Request]Merging 2 scripts

2 posts in this topic

Dear Forum  Users , 

trying to get 2 scripts to work under one script with a little Edit on the script itself to show additional info which is posted on the second script "Monitor Info"

so instead of show 2 windows it would be just one

1st script

#RequireAdmin

#include <Array.au3>
Global $PCName = @ComputerName
Dim $StrSerial ="Serial Number :"
Global $aArray = _IPDetails()
Global $sData = "IP Address: " & $aArray[1] & @LF & _
"MAC Address: " & $aArray[2]
$ObjWMI = ObjGet("winmgmts:")
$ColSettingsBios = $ObjWMI.ExecQuery("Select * from Win32_BIOS")
For $ObjComputer in $ColSettingsBios
$StrSerial = $StrSerial & $ObjComputer.SerialNumber
Next
MsgBox(0,"PC Information Made by Eng.Abdulrhman Mal","PC Name = " & $PCName & @LF& $sData & @LF& $StrSerial)
Func _IPDetails()
    Local $oWMIService = ObjGet("winmgmts:")
    Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[5] = [4]
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            If $oObjectItem.IPAddress(0) == @IPAddress1 Then
                $aReturn[1] = $oObjectItem.IPAddress(0)
                $aReturn[2] = $oObjectItem.MACAddress(0)
               EndIf
        Next
        Return $aReturn
    EndIf
    Return SetError(1, 0, $aReturn)
EndFunc   ;==>_IPDetails
$Result = StringLen($StrSerial)
IF $Result > 15 Then
$StrSerial = StringLeft ( $StrSerial, 15 )
EndIf 









;$ComputerDescription = InputBox("Information Needed", "Please enter the computer description", "")
$ComputerName = InputBox("Information Needed", "Please enter the computer Name", "")

;MsgBox(0, "notice", $ComputerDescription)

ShellExecute("sysdm.cpl")

WinWait("System Properties")
WinWaitActive("System Properties","To use a wizard to join a domain or workgroup")

;Send($ComputerDescription)
;Send("!A")
Send("!C")

WinWait("Computer Name/Domain Changes", "You can change the name and")
WinWaitActive("Computer Name/Domain Changes", "You can change the name and")
Send("!C")
Send( "UJC-00"&$ComputerName)
Send("!D")
Send("{TAB}")
Send("domain name xxxx")
Send("{ENTER}")

WinWait("Windows Security", "OK")
WinWaitActive("Windows Security", "OK")
Send("joind")
Send("{TAB}")
Send("joinadmin")
Send("{TAB}")
Send("{ENTER}")


WinWait("Computer Name/Domain Changes", "Welcome to the GRG domain.")
WinWaitActive("Computer Name/Domain Changes", "Welcome to the GRG domain.")
Send("{ENTER}")

Sleep(15000)
if WinExists("Computer Name/Domain Changes", "OK") Then
    Send("{ENTER}")
EndIf


;if WinExists("Computer Name/Domain Changes", "OK") Then
;   Send("{ENTER}")
;   msgbox(0,"window does exist", "line46")
;EndIf


WinWait("System Properties", "To use a wizard")
WinActivate("System Properties", "To use a wizard")
WinWaitActive("System Properties","To use a wizard")
msgbox(0,"window","the window is active")
ControlClick("System Properties", "To use a wizard", "Button3")
Send("{ENTER}")

;msgbox(0,"pause", "pause here 3")

;WinWait("Computer Name/Domain Changes", "You can change the name and the membership")
;WinWaitActive("Computer Name/Domain Changes", "You can change the name and the membership")
;Send("{ENTER}")

;msgbox(0,"pause", "pause here 4")

;WinWait("System Properties", "To rename this computer or change its domain")
;WinWaitActive("System Properties", "To rename this computer or change its domain")
;Send("{ENTER}")

;WinWait("Computer Name/Domain Changes", "OK")
;WinWaitActive("Computer Name/Domain Changes", "OK")
;Send("{ENTER}")

WinWait("Microsoft Windows", "&Restart Now")
WinWaitActive("Microsoft Windows", "&Restart Now")
Send("!R")

2nd script  "Monitor"


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;Retrieve Monitor Model and Serial
;13 November 2005 by Geert (NL)
;used parts made by archrival (http://www.autoitscript.com/forum/index.php?showtopic=11136)
;Edited by rover 18 June 2008

;Collect EDID strings for all active monitors
Opt("MustDeclareVars", 1)

; ConsoleWrites slow a script if not needed
Global $Debug = True ; change to False or comment out/remove ConsoleWrite() lines if debugging to console not needed

Global $iCounterEDID = 0
Global $asEDID[1], $edidarray[1], $error1, $error2, $error3
Global $iCounterMonitorName = 1, $iCounterMonitorCode, $iCounterMonitorControlFolder
Global $sMonitorName, $sMonitorCode, $sMonitorControlFolder, $sMonitorEDIDRead, $ser, $name, $j

Do
$sMonitorName = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY", $iCounterMonitorName)
$error1 = @error
If $Debug Then ConsoleWrite(@CRLF & '@@ Debug(' & @ScriptLineNumber & ') : $sMonitorName = ' & _
StringStripWS($sMonitorName, 2) & @CRLF & '>Error code: ' & $error1 & @CRLF)
If $sMonitorName <> "" Then
$iCounterMonitorCode = 1
Do
; Search 'monitor code' - e.g. 5&3aba5caf&0&10000080&01&00
$sMonitorCode = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\" & _
$sMonitorName, $iCounterMonitorCode)
$error2 = @error
If $Debug Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sMonitorCode = ' & _
StringStripWS($sMonitorCode, 2) & @CRLF & '>Error code: ' & $error2 & @CRLF)
; Search Control folder - When available, the active monitor is found
$iCounterMonitorControlFolder = 1

Do
$sMonitorControlFolder = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\" & _
$sMonitorName & "\" & $sMonitorCode, $iCounterMonitorControlFolder)
$error3 = @error
If $Debug Then ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sMonitorControlFolder = ' & _
StringStripWS($sMonitorControlFolder, 2) & @CRLF & '>Error code: ' & $error3 & @CRLF)
If $sMonitorControlFolder == "Control" Then; Active monitor found!

Switch RegEnumVal("HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\" & $sMonitorName & _
"\" & $sMonitorCode & "\Device Parameters", 1)
Case "EDID"
$sMonitorEDIDRead = RegRead("HKLM\SYSTEM\CurrentControlSet\Enum\DISPLAY\" & _
$sMonitorName & "\" & $sMonitorCode & "\Device Parameters", "EDID")
If $sMonitorEDIDRead <> "" Then
$iCounterEDID += 1
$asEDID[0] = $iCounterEDID
ReDim $asEDID[UBound($asEDID) + 1]
$asEDID[UBound($asEDID) - 1] = $sMonitorEDIDRead; Add found EDID string to Array
EndIf
Case "BAD_EDID"
$iCounterEDID += 1
$asEDID[0] = $iCounterEDID
ReDim $asEDID[UBound($asEDID) + 1]
$asEDID[UBound($asEDID) - 1] = "BAD_EDID"; Add BAD_EDID string to Array
Case Else
EndSwitch
EndIf
$iCounterMonitorControlFolder += 1; Increase counter to search for next folder
Until $error3 <> 0
$iCounterMonitorCode += 1; Increase counter to search for next 'monitor code' folder
Until $error2 <> 0
EndIf
$iCounterMonitorName += 1; Increase counter to search for next monitor
Until $error1 <> 0

; Decrypt collected EDID strings - Thanks archrival
For $k = 1 To $asEDID[0]
Switch $asEDID[$k]
Case ""
$ser = ""
$name = ""
Case "BAD_EDID"
$ser = "BAD_EDID"
$name = "BAD_EDID"
Case Else
$j = 0
Dim $edidarray[StringLen($asEDID[$k])]
$edidarray[0] = (StringLen($asEDID[$k]) / 2) + 1
For $i = 1 To StringLen($asEDID[$k]) Step 2
$j += 1
$edidarray[$j] = Dec(StringMid($asEDID[$k], $i, 2))
Next
$ser = StringStripWS(_FindMonitorSerial(), 1 + 2)
$name = StringStripWS(_FindMonitorName(), 1 + 2)
EndSwitch

;Show MonitorSerial & MonitorName: no info? -> Your using a notebook right!
MsgBox(64, "Monitor " & $k, "MonitorSerial: " & @TAB & _
$ser & @CRLF & "MonitorName: " & @TAB & $name)
Next

#region - Functions
Func _FindMonitorSerial(); Thanks archrival
Local $sernumstr = "", $sernum = 0, $endstr
For $i = 1 To (UBound($edidarray) / 2) - 4
If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And $edidarray[$i + 2] = "0" _
And $edidarray[$i + 3] = "255" And $edidarray[$i + 4] = "0" Then
$sernum = $i + 4
EndIf
Next
If $sernum <> 0 Then
$endstr = 0
For $i = 1 To 13
If $edidarray[$sernum + $i] = "10" Then
$endstr = 1
Else
If $endstr = 0 Then
$sernumstr &= Chr($edidarray[$sernum + $i])
EndIf
EndIf
Next
EndIf
Return $sernumstr
EndFunc ;==>_FindMonitorSerial

Func _FindMonitorName(); Thanks archrival
Local $n = 0, $namestr = "", $endstr
For $i = 1 To (UBound($edidarray) / 2) - 4
If $edidarray[$i] = "0" And $edidarray[$i + 1] = "0" And _
$edidarray[$i + 2] = "252" And $edidarray[$i + 3] = "0" Then
$n = $i + 3
EndIf
Next
If $n <> 0 Then
$endstr = 0
For $i = 1 To 13
If $edidarray[$n + $i] = "10" Then
$endstr = 1
Else
If $endstr = 0 Then
$namestr &= Chr($edidarray[$n + $i])
EndIf
EndIf
Next
EndIf
Return $namestr
EndFunc ;==>_FindMonitorName
#endregion

your help is appreciated 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1st script:

I would search the forum for "change computer name WMI". IIRC there are a few solutions which make your script more reliable.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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