本帖最后由 szlanpa 于 2011-10-20 08:49 编辑
小弟初学au,现在想编写一个修改计算机名和执行加域的脚本。现在遇到一个问题就是,通过注册表去修改计算机名后,执行已有的加域脚本就会出现错误。在此请教各位高手,怎么去写好这个脚本。
下面是修改注册表的项,不知道有没有拉下了。RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters","Hostname","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Services\Tcpip\Parameters","Hostname","REG_SZ",$Hostname)
终于成功了,原来注册表项少了三项最重要的。。 现在修改后能正常加域,但是前提是必须重启电脑。 RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName","ComputerName","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$Hostname)
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters","Hostname","REG_SZ",$Hostname)
|