顯示具有 VBScript 標籤的文章。 顯示所有文章
顯示具有 VBScript 標籤的文章。 顯示所有文章

2015年6月17日 星期三

[VBScript] 新增 win7 使用者以及修改電腦名稱 並且設定新user自動登入

 Dim user  
 Dim strCommand  
 Dim myKey  
 Dim pasword  
 dim ComputerName  
 user=InputBox("Please Enter User : ","GFI user Setting")  
 pasword=InputBox("Please Enter Password : ","GFI user Setting")  
 'change computername  
 Set objShell = WScript.CreateObject("Wscript.Shell")  
 Set objNetwork = WScript.CreateObject("WScript.Network")  
 ComputerName = objNetwork.ComputerName  
 strCommand= "wmic computersystem where caption='" & ComputerName &"' rename " & user  
 objShell.Run strCommand   
 'add user   
 strCommand= "net user " & user &" " & pasword & " /ADD"  
 objShell.Run strCommand  
 Wscript.Sleep 500  
 'add to Administrators Group  
 strCommand ="net localgroup administrators " & user &" /add"  
 objShell.Run strCommand  
 Wscript.Sleep 500  
 'kill default user  
 strCommand ="net user user /DELETE"  
 objShell.Run strCommand  
 Wscript.Sleep 500  
 'modify autologin =1  
 objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon","1","REG_SZ"  
 objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", user, "REG_SZ"   
 objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword", pasword, "REG_SZ"  
 'reboot  
 strCommand ="shutdown.exe /R /T 5 /C ""Rebooting your computer now!"" "  
 objShell.Run strCommand  
 Wscript.Echo strCommand  

2015年6月16日 星期二

「VBScript」修改win7 IP

 Dim strIPAddress  
 Dim strSubnetMask  
 Dim strGateway  
 Dim strDns1  
 Dim strDns2  
 Dim temp  
 '輸入IP
 temp=InputBox("Please Enter IP : (or input DHCP)","GFI IP Setting")  
 '如果是DHCP就不做任何事
 If temp <> "DHCP" Then  
         strIPAddress = temp  
      strSubnetMask = "255.255.255.0"  
     '計算 Gateway , 本例的Gateway 為 192.168.x.254 ,x為網段  
      intLastDecimal = 1  
      For intCounter = 1 to 3  
           intLastDecimal = InStr(intLastDecimal, strIPAddress , ".") + 1  
      Next  
      iNewLength = intLastDecimal-2  
      strNewIP = Left(strIPAddress , iNewLength )  
      strNewIP =strNewIP & ".254"   
     'end 計算Gateway
      strGateway = strNewIP   
      '定義好DNS
      strDns1 = "168.95.1.1"  
      strDns2 = "8.8.8.8"  
      '宣告使用shell
      Set objShell = WScript.CreateObject("Wscript.Shell")  
      '透過netsh指令來修改IP
      objShell.Run "netsh interface ip set address ""區域連線"" static " & strIPAddress & " " & strSubnetMask & " " & strGateway & " " , 0, True       
     '設定第一組DNS
      objShell.Run "netsh interface ip set dns ""區域連線"" static "& strDns1, 0, True   
      '加入第2組DNS
      objShell.Run "netsh interface ip add dns ""區域連線"" addr="& strDns2, 0, True       
      'Wscript.Echo "netsh interface ip set address ""區域連線"" static " & strIPAddress & " " & strSubnetMask & " " & strGateway & " "   
      Set objShell = Nothing  
      WScript.Quit       
 End If