WindowsAutoLogonRegistration.js
自動ログオンのレジストリを設定する
参考URL
http://support.microsoft.com/kb/315231/ja
単純に自動ログオンの設定に必要なレジストリ値を設定するだけです。具体的には、Microsoftが提供している情報を ご参照下さい。
引数に対する意味は以下の通りです。
userID:ユーザー名
passWD:パスワード
enable:自動ログオンを有効は1を、無効は0を入力
dstlogonsv:ログオン先を入力(ローカルの場合は"LOCAL"と入力)
function AutoWindowsLogonRegistration(userID,passWD,enable,dstlogonsv) { try { var Sh = WScript.CreateObject("WScript.Shell"); if(enable != 1 && enable != 0) { throw "AutoAdminPasswordの設定値が不正です。"; } if(dstlogonsv == "LOCAL") { var oNet = WScript.CreateObject("WScript.Network"); dstlogonsv = oNet.ComputerName; } var regKey = "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\ CurrentVersion\\Winlogon\\"; var userIDKey = regKey+"DefaultUserName"; var passWDKey = regKey+"DefaultPassword"; var enableKey = regKey+"AutoAdminLogon"; var dstlogonsvKey = regKey+"DefaultDomainName"; Sh.RegWrite(userIDKey,userID); Sh.RegWrite(passWDKey,passWD); Sh.RegWrite(enableKey,enable); Sh.RegWrite(dstlogonsvKey,dstlogonsv); return true; } catch(e) { WScript.Echo(e.toString()+"\n\n"+e.message+"例外が発生しました。"); return false; } }
成功すればtrueを、失敗の場合はfalseを返します。