gpt4 book ai didi

vbscript - 权限被拒绝错误 800A0046 'objIE.Document.parentWindow.screen'

转载 作者:行者123 更新时间:2023-12-02 01:42:34 24 4
gpt4 key购买 nike

几年前,我为我的用户编写了一个脚本,让他们在登录 VPN 后登录到公司的驱动器共享。由于 IE 版本升级,该脚本多年来一直运行良好,需要在这里和那里进行一些调整。从今天开始,我无法再让脚本正常运行,错误是:

Line:   93
Char: 5
Error: Permission denied: 'objIE.Document.parentWindow.screen'
Code: 800A0046
Source: Microsoft VBScript runtime error

我不确定发生了什么变化,但在对错误代码和其他项目进行了多次搜索后,我想我会把它发布在这里,看看你们是否可以帮助我解决这个问题。

dim WshNetwork
Dim arrFileLines()

'On Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("Drive Shares.txt", 1)
If Not err.number = 0 then
WScript.Echo "Drive Shares.txt was not found. Please ensure that it is in the same directory as this script file"
WScript.Quit
End If

NumElements = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(NumElements)
arrFileLines(NumElements) = objFile.ReadLine
NumElements = NumElements + 1
Loop
objFile.Close

strPw = GetPassword()

If strPw = "" Then
wScript.Quit
End If

SplitPasswd = Split(StrPW,"*",2)

username = "DEFAULT\" & SplitPasswd(0)
password = SplitPasswd(1)

Set WshNetwork = Wscript.CreateObject("WScript.Network")

For Count = 0 to (NumElements - 1)

SplitDriveInfo = Split(arrFileLines(Count)," ",2)
DriveLetter = SplitDriveInfo(0)
Share = SplitDriveInfo(1)

ExitCode = WshNetwork.MapNetworkDrive(DriveLetter, Share, false, username, password)
ErrorHandler(err.number)

Next

Sub ErrorHandler(ErrorNumber)
Select Case ErrorNumber

Case 0
'OK
Exit Sub

Case -2147024811
'Already Mapped Continue
Exit Sub

Case -2147024843
'No Connection
WScript.Echo "No connection found. Confirm you have an internet connection and that you have the VPN connected."
WScript.Quit

Case -2147024829
'Share not available
WScript.Echo "The drive share you are trying to connect to does not exist on this server."
WScript.Quit

Case -2147023570
'Invalid username or password
WScript.Echo "Invalid username or password. Please try again."
WScript.quit

Case Else
WScript.Echo "Unknown error: " & CStr(ErrorNumber)
WScript.Quit

End Select


End Sub



Function GetPassword()

Dim objIE
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Navigate "about:blank"
objIE.Document.Title = "Login Credentials"
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 320
objIE.Height = 320
With objIE.document.parentWindow.screen
objIE.Left = (.availwidth - objIE.Width ) \ 2
objIE.Top = (.availheight - objIE.Height) \ 2
End With

objIE.Document.Body.InnerHTML = "<DIV align=""center""><P>Please enter your credentials</P>" & vbCrLf _
& "<DIV align=""center""><P>Username</P>" & vbCrLf _
& "<P><INPUT TYPE=""Username"" SIZE=""20"" " _
& "ID=""UserName""></P>" & vbCrLf _
& "<DIV align=""center""><P>Password</P>" & vbCrLf _
& "<P><INPUT TYPE=""password"" SIZE=""20"" " _
& "ID=""Password""></P>" & vbCrLf _
& "<P><INPUT TYPE=""hidden"" ID=""OK"" " _
& "NAME=""OK"" VALUE=""0"">" _
& "<INPUT TYPE=""submit"" VALUE="" OK "" " _
& "OnClick=""VBScript:OK.Value=1""></P></DIV>"
objIE.Visible = True

Do While objIE.Document.All.OK.Value = 0
WScript.Sleep 200
Loop

GetPassword = objIE.Document.All.UserName.Value & "*" & objIE.Document.All.Password.Value
objIE.Quit
Set objIE = Nothing


End Function

如有任何帮助,我们将不胜感激。

最佳答案

Microsoft 发布的修补程序:[KB3025390] http://support.microsoft.com/kb/3025390

如果它在 2014 年 12 月 17 日之前有效,我可以确认卸载此更新将解决问题。

关于vbscript - 权限被拒绝错误 800A0046 'objIE.Document.parentWindow.screen',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27607359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com