#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=G:\素材大全\图标资源\系统图标\20(1).ico
#AutoIt3Wrapper_Res_Comment=计算机随机命名
#AutoIt3Wrapper_Res_Description=计算机随机命名
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=阿福所有 侵权不究
#AutoIt3Wrapper_Res_File_Add=计算机命名.ini
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Global $iniPath, $PR, $PcName,$L
$iniPath=StringTrimRight(@ScriptName,3)&"ini"
$PR=StringMid(iniRead($iniPath, "CompName", "PR", ""),1,3)
PcName()
Func PcName()
Dim $a,$b,$c,$d
$a=Random(65,90,1)
Do
$b=Random(65,90,1)
Until $b<>$a
Do
$c=Random(65,90,1)
Until $c<>$b And $c<>$a
Do
$d=Random(65,90,1)
Until $d<>$c And $d<>$b And $d<>$a
$L=Chr($a)&Chr($b)&Chr($c)&Chr($d)
If $CmdLine[0] > 0 Then
If StringIsAlNum($CmdLine[1])=0 Then
MsgBox(16,"错误","参数错误!"&@CRLF&"参数只能为数字或字母"&@CRLF&"例如:计算机命名.exe pc")
Exit
EndIf
$PR=StringMid($CmdLine[1],1,3)
$PcName=$PR&"-"&StringTrimLeft(@YEAR,2)&@MON&@MDAY&"-"&$L
Else
If $PR="" Then
$PcName="PC"&"-"&StringTrimLeft(@YEAR,2)&@MON&@MDAY&"-"&$L
Else
If StringIsAlNum($PR)=0 Then
MsgBox(16,"错误","配置文件错误!"&@CRLF&"计算机名称前缀只能为数字或字母"&@CRLF&"例如:pc")
Exit
EndIf
$PcName=$PR&"-"&StringTrimLeft(@YEAR,2)&@MON&@MDAY&"-"&$L
EndIf
EndIf
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName", "REG_SZ", $PcName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $PcName)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $PcName)
EndFunc
If Not FileExists($iniPath) Then
FileInstall("计算机命名.ini",@ScriptDir&""&$iniPath,1)
EndIf
TrayTip("通知","计算机已命名为:"&$PcName,5)
Sleep(5000)