1

执行以下脚本时出现此错误。还提到了相同的输出。我确实检查了错误,但没有找到任何修复方法。我正在使用带有 PowerShell 版本的 Windows 10:5.0.10586.0。请求任何人帮助解决此错误。我只能看到带有上述 URL 和可执行文件记事本的 IE 打开。脚本无法执行自动登录。

输出:

PS C:\WINDOWS\system32> C:\Users\admin\Desktop\Test.ps1
未指定的错误。
在 C:\Users\admin\Desktop\Test.ps1:35 char:1
+ $IE.Document.getElementById(“电子邮件”).value = $Username
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId:System.Runtime.InteropServices.COMException

未指定的错误。
在 C:\Users\admin\Desktop\Test.ps1:36 char:1
+ $IE.Document.getElementById(“signIn”).Click()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId:System.Runtime.InteropServices.COMException

未指定的错误。
在 C:\Users\admin\Desktop\Test.ps1:37 char:1
+ $IE.Document.getElementByID(“密码”).value=$Password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId:System.Runtime.InteropServices.COMException

未指定的错误。
在 C:\Users\admin\Desktop\Test.ps1:38 char:1
+ $IE.Document.getElementById(“signIn”).Click()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId:System.Runtime.InteropServices.COMException

脚本:

# Edit this to be the URL or IP address of the site to launch on login
$Url = "www.gmail.com"

# Edit this to be the username
$Username= "xxxx@gmail.com"

# Edit this to the corresponding password
$Password= "xxxxx"

# Edit this to be the path to the executable.  Include the executable 
# file name as well.
$Executable = "c:\windows\system32\notepad.exe"

# Invoke Internet Explorer
$IE = New-Object -com internetexplorer.application;
$IE.Visible = $true;
$IE.Navigate($url);

# Wait a few seconds and then launch the executable.
while ($IE.Busy -eq $true) {
  Start-Sleep -Milliseconds 5000;
}

# The following UsernameElement, PasswordElement, and LoginElement need
# to be modified first.  See the notes at the top of the script for more
# details.
$IE.Document.getElementById("Email").value = $Username
$IE.Document.getElementById("signIn").Click()
$IE.Document.getElementByID("Passwd").value=$Password
$IE.Document.getElementById("signIn").Click()

while ($IE.Busy -eq $true) {
  Start-Sleep -Milliseconds 5000;
}

Invoke-Item $Executable
4

1 回答 1

0

如果您的邮件地址无效,您将永远不会收到密码字段,而是一条错误消息。对我来说,它正在工作。

于 2016-01-25T07:15:22.190 回答