Код:
$ip = '192.168.100.' & $ComputerNumber
If @IPAddress1 <> $ip Then
RunWait (@COMSPEC & ' /c chcp 1251 && ' & @SystemDir & '\netsh.exe interface ip dump > netsh.cfg', @ScriptDir, @SW_HIDE)
FileWriteLine(@ScriptDir & "\error.log", StringFormat("%s:%s:%s %s-%s-%s Старый IP %s, надо менять", @HOUR, @MIN, @SEC, @MDAY, @MON, @YEAR, @IPAddress1))
$file = FileOpen(@ScriptDir & '\netsh.cfg', 0)
; Check if file opened for reading OK
If $file = -1 Then
FileWriteLine(@ScriptDir & "\error.log", StringFormat("%s:%s:%s %s-%s-%s Не могу открыть файл netsh.cfg", @HOUR, @MIN, @SEC, @MDAY, @MON, @YEAR))
Exit
EndIf
; Read in lines of text until the EOF is reached
For $i = 1 To 60
$line = FileReadLine($file)
If StringInStr($line, 'set address name="') = 1 Then ExitLoop
If $i = 60 Then Shutdown (6)
Sleep (1000)
Next
$line = StringTrimLeft( $line, 17 )
$line = StringTrimRight( $line, StringLen($line) - StringInStr($line, 'source') + 2)
FileClose($file)
RunWait (@SystemDir & '\netsh.exe interface ip set address name=' & $line & ' source=static addr=' & $ip & ' mask=255.255.255.0 gateway=none', @SystemDir, @SW_HIDE)
FileWriteLine(@ScriptDir & "\error.log", StringFormat("%s:%s:%s %s-%s-%s Сменили IP на: %s", @HOUR, @MIN, @SEC, @MDAY, @MON, @YEAR, $ip))
$Restart = 'Yes' ; требуется перезагрузка
EndIf