c#のコードでホスト名を変更したい。OSはxpです。
ありがとう。
ManagementClass mComputerSystem = new ManagementClass("Win32_ComputerSystem");
ManagementBaseObject outParams;
ManagementBaseObject objNewComputerName = mComputerSystem.GetMethodParameters("Rename");
objNewComputerName["Name"] = "NEWNAMEHERE";
outParams = mComputerSystem.InvokeMethod("Rename", objNewComputerName, null);
これらのレジストリ キーを編集し、再起動します。Computer Browser と Server and Client サービスを再起動するだけでうまくいくかもしれませんが、私はそれを疑っています。
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName