[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] vbs 修改一下脚本做个输入用户名密码的窗口。有偿求助

本帖最后由 赚他一个亿 于 2022-4-14 15:58 编辑
  1. On Error Resume Next
  2. Err.Clear
  3. Set oWsh = CreateObject("WScript.Shell")
  4. sRegValue = oWsh.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs")
  5. If sRegValue = "" Then
  6. Dim reval_all
  7. Set objnet = CreateObject ("WScript.Network")
  8. Set R = CreateObject("WScript.Shell")
  9. reval_all = InputBox ("当前计算机名称:" & objnet.ComputerName & chr(10)&chr(13) & "当前登录名:" & objnet.username & chr(10)&chr(13)  &"请输入新的计算机名和登录账户,用”,“分开.(例子:zhangsan-pc,zhangsan)"  & chr(10)&chr(13) & "注:登陆账户为登陆此计算机的域账户。" ,"请输入计算名和登录名")
  10. arr1 = split(reval_all,",")
  11. reval = arr1(0)
  12. On Error Resume Next
  13. strComputer = "."
  14. Set objWMIService = GetObject("winmgmts:" _
  15. & "{impersonationLevel=impersonate}!\\" _
  16. & strComputer & "\root\cimv2")
  17. Set colComputers = objWMIService.ExecQuery _
  18. ("Select * from Win32_ComputerSystem")
  19. For Each objComputer in colComputers
  20. errReturn = ObjComputer.Rename (reval)
  21. If reval <> "" Then
  22. Dim AutoRunProgram
  23. Set AutoRunProgram = WScript.CreateObject("WScript.shell")
  24. RegPath ="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
  25. Type_Name = "REG_SZ"
  26. Key_Name = "rr.vbs"
  27. strComputer = "."
  28. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  29. Set colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'wscript.exe' OR Name = 'cscript.exe'")
  30. For Each objItem in colItems
  31. lmq= objItem.CommandLine
  32. lmq= replace(lmq,Chr(34),",")
  33. arr = split(lmq,",")
  34. Next
  35. Key_data = arr(3)
  36. AutorunProgram.RegWrite regpath&Key_Name,Key_data,Type_Name
  37. AutorunProgram.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\loginName",arr1(1),Type_Name
  38. return=MsgBox ("Please Reboot Computer?",vbokcancel+vbexclamation,"tips!")
  39. If return=vbok Then
  40. R.run("Shutdown.exe -r -t 0")
  41. End if
  42. End If
  43. Next
  44. End If
  45. if sRegValue <> "" then
  46. dim domain
  47. set domain =createobject("wscript.shell")
  48. Const JOIN_DOMAIN = 1
  49. Const ACCT_CREATE = 2
  50. Const ACCT_DELETE = 4
  51. Const WIN9X_UPGRADE = 16
  52. Const DOMAIN_JOIN_IF_JOINED = 32
  53. Const JOIN_UNSECURE = 64
  54. Const MACHINE_PASSWORD_PASSED = 128
  55. Const DEFERRED_SPN_SET = 256
  56. Const INSTALL_INVOCATION = 262144
  57. 'Domain Name
  58. strDomain = "test.com"
  59. 'administrator member password
  60. strPassword = "123456"
  61. 'administrator member
  62. strUser = "administrator"
  63. Set objNetwork =CreateObject("WScript.Network")
  64. strComputer = objNetwork.ComputerName
  65. Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"& _
  66. strComputer &"\root\cimv2:Win32_ComputerSystem.Name='" & _
  67. strComputer & "'")
  68. ReturnValue =objComputer.JoinDomainOrWorkGroup(strDomain, _
  69. strPassword, strDomain & "\"& strUser, NULL, _
  70. JOIN_DOMAIN + ACCT_CREATE)
  71.    dim wsh
  72. set wsh=wscript.createobject("wscript.shell")
  73. wsh.regdelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs"
  74. wscript.echo "Join Domain Success!"
  75. Dim oWshNetwork
  76. Set oWshNetwork = WScript.CreateObject("WScript.Network")
  77. strComputer = oWshNetwork.ComputerName
  78. sFlag=0
  79. On Error Resume Next
  80. 'Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
  81. 'For Each objUser In colGroups.Members
  82.    
  83. 'Next
  84. strTestString = "/" & strComputer & "/"
  85. Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
  86. For Each objUser In colGroups.Members
  87. If InStr(objUser.AdsPath, strTestString) Then
  88. 'Wscript.Echo "Local user: " & objUser.Name
  89. 'msgbox(objUser.ADsPath)
  90. Else
  91. IF objuser.Name = "DomainUser" Then
  92.    sFlag=1                       
  93. end if
  94.   
  95.   
  96. End If
  97. Next
  98. if sFlag=0 then
  99. 'Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
  100. '
  101. Set oWsh = CreateObject("WScript.Shell")
  102. reval = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName")
  103. wsh.regdelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName"
  104. adspath = "WinNT://test/" & reval
  105. 'msgbox(adspath)
  106. Set objUser = GetObject(adspath)
  107. colGroups.Add(objUser.ADsPath)
  108. end if      
  109. wscript.echo  "Added Finish"
  110. end if
复制代码
下边这段是我需要做个手工做个输入用户名密码弹窗,这样子密码就不会泄露,每个人用每个人的密码加入域控。这个是我复制别人的需要稍微修改一下,我不知道怎么把这一段改成这个弹窗输入模式。
        'administrator member password
        strPassword = "123456"
        'administrator member
        strUser = "administrator"

  1.     On Error Resume Next
  2.     Err.Clear
  3.     Set oWsh = CreateObject("WScript.Shell")
  4.     sRegValue = oWsh.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs")
  5.     If sRegValue = "" Then
  6.     Dim reval_all
  7.     Set objnet = CreateObject ("WScript.Network")
  8.     Set R = CreateObject("WScript.Shell")
  9.     reval_all = InputBox ("当前计算机名称:" & objnet.ComputerName & chr(10)&chr(13) & "当前登录名:" & objnet.username & chr(10)&chr(13)  &"请输入新的计算机名和登录账户,用”,“分开.(例子:zhangsan-pc,zhangsan)"  & chr(10)&chr(13) & "注:登陆账户为登陆此计算机的域账户。" ,"请输入计算名和登录名")
  10.    
  11.     arr1 = split(reval_all,",")
  12.     reval = arr1(0)
  13.     On Error Resume Next
  14.     strComputer = "."
  15.     Set objWMIService = GetObject("winmgmts:" _
  16.     & "{impersonationLevel=impersonate}!\\" _
  17.     & strComputer & "\root\cimv2")
  18.     Set colComputers = objWMIService.ExecQuery _
  19.     ("Select * from Win32_ComputerSystem")
  20.    
  21.     For Each objComputer in colComputers
  22.     errReturn = ObjComputer.Rename (reval)
  23.     If reval <> "" Then
  24.     Dim AutoRunProgram
  25.     Set AutoRunProgram = WScript.CreateObject("WScript.shell")
  26.     RegPath ="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
  27.     Type_Name = "REG_SZ"
  28.     Key_Name = "rr.vbs"
  29.     strComputer = "."
  30.     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  31.     Set colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'wscript.exe' OR Name = 'cscript.exe'")
  32.     For Each objItem in colItems
  33.     lmq= objItem.CommandLine
  34.     lmq= replace(lmq,Chr(34),",")
  35.     arr = split(lmq,",")
  36.     Next
  37.     Key_data = arr(3)
  38.     AutorunProgram.RegWrite regpath&Key_Name,Key_data,Type_Name
  39.     AutorunProgram.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\loginName",arr1(1),Type_Name
  40.     return=MsgBox ("Please Reboot Computer?",vbokcancel+vbexclamation,"tips!")
  41.     If return=vbok Then
  42.     R.run("Shutdown.exe -r -t 0")
  43.     End if
  44.     End If
  45.     Next
  46.     End If
  47.     if sRegValue <> "" then
  48.     dim domain
  49.     set domain =createobject("wscript.shell")
  50.     Const JOIN_DOMAIN = 1
  51.     Const ACCT_CREATE = 2
  52.     Const ACCT_DELETE = 4
  53.     Const WIN9X_UPGRADE = 16
  54.     Const DOMAIN_JOIN_IF_JOINED = 32
  55.     Const JOIN_UNSECURE = 64
  56.     Const MACHINE_PASSWORD_PASSED = 128
  57.     Const DEFERRED_SPN_SET = 256
  58.     Const INSTALL_INVOCATION = 262144
  59.     'Domain Name
  60.     strDomain = "test.com"
  61.     strPassword=inputbox("Password", "Password", "Password")
  62.         strUser=inputbox("User", "User", "User")
  63.     Set objNetwork =CreateObject("WScript.Network")
  64.     strComputer = objNetwork.ComputerName
  65.     Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"& _
  66.     strComputer &"\root\cimv2:Win32_ComputerSystem.Name='" & _
  67.     strComputer & "'")
  68.     ReturnValue =objComputer.JoinDomainOrWorkGroup(strDomain, _
  69.     strPassword, strDomain & "\"& strUser, NULL, _
  70.     JOIN_DOMAIN + ACCT_CREATE)
  71.        dim wsh
  72.     set wsh=wscript.createobject("wscript.shell")
  73.     wsh.regdelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs"
  74.     wscript.echo "Join Domain Success!"
  75.    
  76.    
  77.    
  78.     Dim oWshNetwork
  79.     Set oWshNetwork = WScript.CreateObject("WScript.Network")
  80.     strComputer = oWshNetwork.ComputerName
  81.     sFlag=0
  82.     On Error Resume Next
  83.     'Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
  84.     'For Each objUser In colGroups.Members
  85.    
  86.        
  87.     'Next
  88.     strTestString = "/" & strComputer & "/"
  89.     Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
  90.     For Each objUser In colGroups.Members
  91.     If InStr(objUser.AdsPath, strTestString) Then
  92.     'Wscript.Echo "Local user: " & objUser.Name
  93.     'msgbox(objUser.ADsPath)
  94.     Else
  95.     IF objuser.Name = "DomainUser" Then
  96.        sFlag=1                       
  97.    
  98.     end if
  99.       
  100.       
  101.    
  102.     End If
  103.     Next
  104.     if sFlag=0 then
  105.     'Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
  106.     '
  107.     Set oWsh = CreateObject("WScript.Shell")
  108.     reval = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName")
  109.     wsh.regdelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName"
  110.    
  111.     adspath = "WinNT://test/" & reval
  112.     'msgbox(adspath)
  113.     Set objUser = GetObject(adspath)
  114.     colGroups.Add(objUser.ADsPath)
  115.     end if      
  116.     wscript.echo  "Added Finish"
  117.    
  118.     end if
复制代码
https://pc.woozooo.com/mydisk.php

TOP

返回列表