AutoIT 和 VBS - 从 Windows 锁定屏幕将 PC 添加到域
AutoIT & VBS - Adding PC to a Domain from the Windows lock screen
我正在编写 AutoIT(和 VBS)脚本,以便从 Windows (7) 锁定屏幕将 PC 加入域。我已经用我的脚本替换了 system32 文件夹中的 Utilman.exe。当在 Windows 锁定屏幕上单击“轻松访问”按钮时,我的 Autoit GUI 会出现并显示 IP、PC 名称,并为最终用户提供一些自助按钮。
我的 GUI 上的一个按钮调用了一个函数,用于在计算机脱离域后将其重新加入域。我的问题是,在锁定屏幕上,加入域按钮 运行s 但没有将 PC 加入域。即使重启后。如果我登录到管理员帐户并单击相同的加入域按钮,PC 将毫无问题地添加到域中。这让我很困惑,因为我的脚本 运行s 作为锁定屏幕上的 SYSTEM 用户。非常感谢有关此问题的任何意见或建议!
我用来将PC连接到域的函数如下。它在登录到管理员帐户时有效,但不会从 Windows 锁定屏幕
将 PC 加入域
编辑:域脚本来自这个例子:
http://www.vbsedit.com/scripts/ad/computer/scr_5.asp
从锁定屏幕 运行 脚本的想法来自下面的示例。我用我的脚本替换了 Utilman.exe,将我的脚本命名为 Utilman.exe 并将其放在 system32 文件夹中
https://www.technibble.com/bypass-windows-logons-utilman/
Func joinDomain()
$file = FileOpen("C:\IT\joinDomain.vbs", 1)
FileWriteLine($file, 'Const JOIN_DOMAIN = 1')
FileWriteLine($file, 'Const ACCT_CREATE = 2')
FileWriteLine($file, 'Const ACCT_DELETE = 4')
FileWriteLine($file, 'Const WIN9X_UPGRADE = 16')
FileWriteLine($file, 'Const DOMAIN_JOIN_IF_JOINED = 32')
FileWriteLine($file, 'Const JOIN_UNSECURE = 64')
FileWriteLine($file, 'Const MACHINE_PASSWORD_PASSED = 128')
FileWriteLine($file, 'Const DEFERRED_SPN_SET = 256')
FileWriteLine($file, 'Const INSTALL_INVOCATION = 262144')
FileWriteLine($file, ' ')
FileWriteLine($file, 'strDomain = "Domain.net"')
FileWriteLine($file, 'strPassword = "joinDomainPassword"')
FileWriteLine($file, 'strUser = "SDSUser"')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set objNetwork = CreateObject("WScript.Network")')
FileWriteLine($file, ' strComputer = objNetwork.ComputerName')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\" & _')
FileWriteLine($file, ' strComputer & "\root\cimv2:Win32_ComputerSystem.Name=''" & _ ')
FileWriteLine($file, ' strComputer & "''") ')
FileWriteLine($file, ' ')
FileWriteLine($file, 'ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _')
FileWriteLine($file, ' strPassword, strDomain & "\" & strUser, NULL, _')
FileWriteLine($file, ' JOIN_DOMAIN + ACCT_CREATE)')
FileClose($file)
Sleep(100)
RunWait(@ComSpec & " /c " & 'wscript.exe C:\IT\joinDomain.vbs', @SystemDir, @SW_HIDE)
sleep(1000)
FileDelete("C:\IT\joinDomain.vbs")
messageBox()
EndFunc
Here is a full AutoIT version of the VBS script above. It works fine when logged in as an admin but I get an error 2717 when I call
the same function from the Windows lock screen.
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
Const $DOMAIN = "Domain.net"
Const $ADMINKENNWORT = "Password"
Const $ADMIN = "SDUser"
Const $COMPUTER = @ComputerName
$objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\" & $COMPUTER & "\root\cimv2:Win32_ComputerSystem.Name='" & $COMPUTER & "'")
$Result = $objComputer.JoinDomainOrWorkGroup($DOMAIN, $ADMINKENNWORT, $DOMAIN & "\" & $ADMIN, "", $JOIN_DOMAIN + $ACCT_CREATE)
If ($Result <> 0) Then
MsgBox(0, "Error Joining the Domain", $COMPUTER & " Error code: " & $Result )
EndIf
我认为您只是 运行 参与供股。尝试将此添加到脚本的顶部:
#RequireAdmin
使用wmi.here是一个UDF。
Func _SetWorkGroup($WorkGroup)
;================================
;Usage:_SetWorkGroup(WprkGroup Name)
;Make By Sanhen
;================================
Local $objNetwork, $strComputer
$objNetwork = ObjCreate("WScript.Network")
$strComputer = $objNetwork.ComputerName
$objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\" & _
$strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _
& $strComputer & "'")
Return $objComputer.JoinDomainOrWorkGroup($WorkGroup)
EndFunc ;==>_SetWorkGroup
我正在编写 AutoIT(和 VBS)脚本,以便从 Windows (7) 锁定屏幕将 PC 加入域。我已经用我的脚本替换了 system32 文件夹中的 Utilman.exe。当在 Windows 锁定屏幕上单击“轻松访问”按钮时,我的 Autoit GUI 会出现并显示 IP、PC 名称,并为最终用户提供一些自助按钮。
我的 GUI 上的一个按钮调用了一个函数,用于在计算机脱离域后将其重新加入域。我的问题是,在锁定屏幕上,加入域按钮 运行s 但没有将 PC 加入域。即使重启后。如果我登录到管理员帐户并单击相同的加入域按钮,PC 将毫无问题地添加到域中。这让我很困惑,因为我的脚本 运行s 作为锁定屏幕上的 SYSTEM 用户。非常感谢有关此问题的任何意见或建议!
我用来将PC连接到域的函数如下。它在登录到管理员帐户时有效,但不会从 Windows 锁定屏幕
将 PC 加入域编辑:域脚本来自这个例子: http://www.vbsedit.com/scripts/ad/computer/scr_5.asp
从锁定屏幕 运行 脚本的想法来自下面的示例。我用我的脚本替换了 Utilman.exe,将我的脚本命名为 Utilman.exe 并将其放在 system32 文件夹中 https://www.technibble.com/bypass-windows-logons-utilman/
Func joinDomain()
$file = FileOpen("C:\IT\joinDomain.vbs", 1)
FileWriteLine($file, 'Const JOIN_DOMAIN = 1')
FileWriteLine($file, 'Const ACCT_CREATE = 2')
FileWriteLine($file, 'Const ACCT_DELETE = 4')
FileWriteLine($file, 'Const WIN9X_UPGRADE = 16')
FileWriteLine($file, 'Const DOMAIN_JOIN_IF_JOINED = 32')
FileWriteLine($file, 'Const JOIN_UNSECURE = 64')
FileWriteLine($file, 'Const MACHINE_PASSWORD_PASSED = 128')
FileWriteLine($file, 'Const DEFERRED_SPN_SET = 256')
FileWriteLine($file, 'Const INSTALL_INVOCATION = 262144')
FileWriteLine($file, ' ')
FileWriteLine($file, 'strDomain = "Domain.net"')
FileWriteLine($file, 'strPassword = "joinDomainPassword"')
FileWriteLine($file, 'strUser = "SDSUser"')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set objNetwork = CreateObject("WScript.Network")')
FileWriteLine($file, ' strComputer = objNetwork.ComputerName')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\" & _')
FileWriteLine($file, ' strComputer & "\root\cimv2:Win32_ComputerSystem.Name=''" & _ ')
FileWriteLine($file, ' strComputer & "''") ')
FileWriteLine($file, ' ')
FileWriteLine($file, 'ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _')
FileWriteLine($file, ' strPassword, strDomain & "\" & strUser, NULL, _')
FileWriteLine($file, ' JOIN_DOMAIN + ACCT_CREATE)')
FileClose($file)
Sleep(100)
RunWait(@ComSpec & " /c " & 'wscript.exe C:\IT\joinDomain.vbs', @SystemDir, @SW_HIDE)
sleep(1000)
FileDelete("C:\IT\joinDomain.vbs")
messageBox()
EndFunc
Here is a full AutoIT version of the VBS script above. It works fine when logged in as an admin but I get an error 2717 when I call the same function from the Windows lock screen.
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
Const $DOMAIN = "Domain.net"
Const $ADMINKENNWORT = "Password"
Const $ADMIN = "SDUser"
Const $COMPUTER = @ComputerName
$objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\" & $COMPUTER & "\root\cimv2:Win32_ComputerSystem.Name='" & $COMPUTER & "'")
$Result = $objComputer.JoinDomainOrWorkGroup($DOMAIN, $ADMINKENNWORT, $DOMAIN & "\" & $ADMIN, "", $JOIN_DOMAIN + $ACCT_CREATE)
If ($Result <> 0) Then
MsgBox(0, "Error Joining the Domain", $COMPUTER & " Error code: " & $Result )
EndIf
我认为您只是 运行 参与供股。尝试将此添加到脚本的顶部:
#RequireAdmin
使用wmi.here是一个UDF。
Func _SetWorkGroup($WorkGroup)
;================================
;Usage:_SetWorkGroup(WprkGroup Name)
;Make By Sanhen
;================================
Local $objNetwork, $strComputer
$objNetwork = ObjCreate("WScript.Network")
$strComputer = $objNetwork.ComputerName
$objComputer = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\" & _
$strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" _
& $strComputer & "'")
Return $objComputer.JoinDomainOrWorkGroup($WorkGroup)
EndFunc ;==>_SetWorkGroup