标题: [问题求助] vbs 修改一下脚本做个输入用户名密码的窗口。有偿求助 [打印本页]
作者: 赚他一个亿 时间: 2022-4-13 13:44 标题: vbs 修改一下脚本做个输入用户名密码的窗口。有偿求助
本帖最后由 赚他一个亿 于 2022-4-14 15:58 编辑
- On Error Resume Next
- Err.Clear
- Set oWsh = CreateObject("WScript.Shell")
- sRegValue = oWsh.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs")
- If sRegValue = "" Then
- Dim reval_all
- Set objnet = CreateObject ("WScript.Network")
- Set R = CreateObject("WScript.Shell")
- reval_all = InputBox ("当前计算机名称:" & objnet.ComputerName & chr(10)&chr(13) & "当前登录名:" & objnet.username & chr(10)&chr(13) &"请输入新的计算机名和登录账户,用”,“分开.(例子:zhangsan-pc,zhangsan)" & chr(10)&chr(13) & "注:登陆账户为登陆此计算机的域账户。" ,"请输入计算名和登录名")
-
- arr1 = split(reval_all,",")
- reval = arr1(0)
- On Error Resume Next
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" _
- & strComputer & "\root\cimv2")
- Set colComputers = objWMIService.ExecQuery _
- ("Select * from Win32_ComputerSystem")
-
- For Each objComputer in colComputers
- errReturn = ObjComputer.Rename (reval)
- If reval <> "" Then
- Dim AutoRunProgram
- Set AutoRunProgram = WScript.CreateObject("WScript.shell")
- RegPath ="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
- Type_Name = "REG_SZ"
- Key_Name = "rr.vbs"
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'wscript.exe' OR Name = 'cscript.exe'")
- For Each objItem in colItems
- lmq= objItem.CommandLine
- lmq= replace(lmq,Chr(34),",")
- arr = split(lmq,",")
- Next
- Key_data = arr(3)
- AutorunProgram.RegWrite regpath&Key_Name,Key_data,Type_Name
- AutorunProgram.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\loginName",arr1(1),Type_Name
- return=MsgBox ("Please Reboot Computer?",vbokcancel+vbexclamation,"tips!")
- If return=vbok Then
- R.run("Shutdown.exe -r -t 0")
- End if
- End If
- Next
- End If
- if sRegValue <> "" then
- dim domain
- set domain =createobject("wscript.shell")
- Const JOIN_DOMAIN = 1
- Const ACCT_CREATE = 2
- Const ACCT_DELETE = 4
- Const WIN9X_UPGRADE = 16
- Const DOMAIN_JOIN_IF_JOINED = 32
- Const JOIN_UNSECURE = 64
- Const MACHINE_PASSWORD_PASSED = 128
- Const DEFERRED_SPN_SET = 256
- Const INSTALL_INVOCATION = 262144
- 'Domain Name
- strDomain = "test.com"
- 'administrator member password
- strPassword = "123456"
- 'administrator member
- strUser = "administrator"
- Set objNetwork =CreateObject("WScript.Network")
- strComputer = objNetwork.ComputerName
- Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"& _
- strComputer &"\root\cimv2:Win32_ComputerSystem.Name='" & _
- strComputer & "'")
- ReturnValue =objComputer.JoinDomainOrWorkGroup(strDomain, _
- strPassword, strDomain & "\"& strUser, NULL, _
- JOIN_DOMAIN + ACCT_CREATE)
- dim wsh
- set wsh=wscript.createobject("wscript.shell")
- wsh.regdelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs"
- wscript.echo "Join Domain Success!"
-
-
-
- Dim oWshNetwork
- Set oWshNetwork = WScript.CreateObject("WScript.Network")
-
- strComputer = oWshNetwork.ComputerName
- sFlag=0
- On Error Resume Next
- 'Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
-
- 'For Each objUser In colGroups.Members
-
-
- 'Next
-
- strTestString = "/" & strComputer & "/"
-
- Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
-
- For Each objUser In colGroups.Members
- If InStr(objUser.AdsPath, strTestString) Then
- 'Wscript.Echo "Local user: " & objUser.Name
- 'msgbox(objUser.ADsPath)
- Else
- IF objuser.Name = "DomainUser" Then
- sFlag=1
-
- end if
-
-
-
- End If
- Next
- if sFlag=0 then
-
- 'Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
- '
- Set oWsh = CreateObject("WScript.Shell")
- reval = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName")
- wsh.regdelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName"
-
- adspath = "WinNT://test/" & reval
- 'msgbox(adspath)
- Set objUser = GetObject(adspath)
- colGroups.Add(objUser.ADsPath)
- end if
- wscript.echo "Added Finish"
-
- end if
复制代码
下边这段是我需要做个手工做个输入用户名密码弹窗,这样子密码就不会泄露,每个人用每个人的密码加入域控。这个是我复制别人的需要稍微修改一下,我不知道怎么把这一段改成这个弹窗输入模式。
'administrator member password
strPassword = "123456"
'administrator member
strUser = "administrator"
作者: LJY4.0 时间: 2022-6-5 12:00
- On Error Resume Next
- Err.Clear
- Set oWsh = CreateObject("WScript.Shell")
- sRegValue = oWsh.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs")
- If sRegValue = "" Then
- Dim reval_all
- Set objnet = CreateObject ("WScript.Network")
- Set R = CreateObject("WScript.Shell")
- reval_all = InputBox ("当前计算机名称:" & objnet.ComputerName & chr(10)&chr(13) & "当前登录名:" & objnet.username & chr(10)&chr(13) &"请输入新的计算机名和登录账户,用”,“分开.(例子:zhangsan-pc,zhangsan)" & chr(10)&chr(13) & "注:登陆账户为登陆此计算机的域账户。" ,"请输入计算名和登录名")
-
- arr1 = split(reval_all,",")
- reval = arr1(0)
- On Error Resume Next
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:" _
- & "{impersonationLevel=impersonate}!\\" _
- & strComputer & "\root\cimv2")
- Set colComputers = objWMIService.ExecQuery _
- ("Select * from Win32_ComputerSystem")
-
- For Each objComputer in colComputers
- errReturn = ObjComputer.Rename (reval)
- If reval <> "" Then
- Dim AutoRunProgram
- Set AutoRunProgram = WScript.CreateObject("WScript.shell")
- RegPath ="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
- Type_Name = "REG_SZ"
- Key_Name = "rr.vbs"
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colItems = objWMIService.ExecQuery("Select * From Win32_Process Where Name = 'wscript.exe' OR Name = 'cscript.exe'")
- For Each objItem in colItems
- lmq= objItem.CommandLine
- lmq= replace(lmq,Chr(34),",")
- arr = split(lmq,",")
- Next
- Key_data = arr(3)
- AutorunProgram.RegWrite regpath&Key_Name,Key_data,Type_Name
- AutorunProgram.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\loginName",arr1(1),Type_Name
- return=MsgBox ("Please Reboot Computer?",vbokcancel+vbexclamation,"tips!")
- If return=vbok Then
- R.run("Shutdown.exe -r -t 0")
- End if
- End If
- Next
- End If
- if sRegValue <> "" then
- dim domain
- set domain =createobject("wscript.shell")
- Const JOIN_DOMAIN = 1
- Const ACCT_CREATE = 2
- Const ACCT_DELETE = 4
- Const WIN9X_UPGRADE = 16
- Const DOMAIN_JOIN_IF_JOINED = 32
- Const JOIN_UNSECURE = 64
- Const MACHINE_PASSWORD_PASSED = 128
- Const DEFERRED_SPN_SET = 256
- Const INSTALL_INVOCATION = 262144
- 'Domain Name
- strDomain = "test.com"
- strPassword=inputbox("Password", "Password", "Password")
- strUser=inputbox("User", "User", "User")
- Set objNetwork =CreateObject("WScript.Network")
- strComputer = objNetwork.ComputerName
- Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"& _
- strComputer &"\root\cimv2:Win32_ComputerSystem.Name='" & _
- strComputer & "'")
- ReturnValue =objComputer.JoinDomainOrWorkGroup(strDomain, _
- strPassword, strDomain & "\"& strUser, NULL, _
- JOIN_DOMAIN + ACCT_CREATE)
- dim wsh
- set wsh=wscript.createobject("wscript.shell")
- wsh.regdelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\rr.vbs"
- wscript.echo "Join Domain Success!"
-
-
-
- Dim oWshNetwork
- Set oWshNetwork = WScript.CreateObject("WScript.Network")
-
- strComputer = oWshNetwork.ComputerName
- sFlag=0
- On Error Resume Next
- 'Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
-
- 'For Each objUser In colGroups.Members
-
-
- 'Next
-
- strTestString = "/" & strComputer & "/"
-
- Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
-
- For Each objUser In colGroups.Members
- If InStr(objUser.AdsPath, strTestString) Then
- 'Wscript.Echo "Local user: " & objUser.Name
- 'msgbox(objUser.ADsPath)
- Else
- IF objuser.Name = "DomainUser" Then
- sFlag=1
-
- end if
-
-
-
- End If
- Next
- if sFlag=0 then
-
- 'Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
- '
- Set oWsh = CreateObject("WScript.Shell")
- reval = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName")
- wsh.regdelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\loginName"
-
- adspath = "WinNT://test/" & reval
- 'msgbox(adspath)
- Set objUser = GetObject(adspath)
- colGroups.Add(objUser.ADsPath)
- end if
- wscript.echo "Added Finish"
-
- end if
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |