Vbscript 如何运行脚本而不显示错误
我的权限被拒绝以用户权限运行脚本,我想要的是,即使我的权限被拒绝,脚本也不会显示该错误。请参阅 如果您没有在错误恢复下一步时使用Vbscript 如何运行脚本而不显示错误,vbscript,Vbscript,我的权限被拒绝以用户权限运行脚本,我想要的是,即使我的权限被拒绝,脚本也不会显示该错误。请参阅 如果您没有在错误恢复下一步时使用语句,则发生的任何运行时错误都是致命的; i、 e.显示错误消息,执行停止 On Error Resume Next导致执行继续,该语句紧跟在导致运行时错误的语句之后,或者紧跟在包含On Error Resume Next语句的过程的最新调用之后 这允许在运行时出错的情况下继续执行。然后可以在过程中内联构建错误处理例程 如果调用了另一个过程,则“On Error Res
语句,则发生的任何运行时错误都是致命的;
i、 e.显示错误消息,执行停止
On Error Resume Next
导致执行继续,该语句紧跟在导致运行时错误的语句之后,或者紧跟在包含On Error Resume Next
语句的过程的最新调用之后
这允许在运行时出错的情况下继续执行。然后可以在过程中内联构建错误处理例程
如果调用了另一个过程,则“On Error Resume Next
On Error Resume Next”语句将变为非活动状态,因此,如果希望在该例程中进行内联错误处理,则应在每个被调用的例程中执行“On Error Resume NextOn Error Resume Next”语句
Dim oShell : Set oShell = CreateObject("WScript.Shell")
dim filesys
oShell.Run "taskkill /F /IM mysqld.exe", , True
Dim WShell
Set fso = CreateObject("Scripting.FileSystemObject")
file = ("C:\xampp\mysql\bin\mysqld.exe")
fso.DeleteFile file
Set WShell = Nothing
指
如果您没有在错误恢复下一步时使用语句,则发生的任何运行时错误都是致命的;
i、 e.显示错误消息,执行停止
On Error Resume Next
导致执行继续,该语句紧跟在导致运行时错误的语句之后,或者紧跟在包含On Error Resume Next
语句的过程的最新调用之后
这允许在运行时出错的情况下继续执行。然后可以在过程中内联构建错误处理例程
如果调用了另一个过程,则“On Error Resume Next
On Error Resume Next”语句将变为非活动状态,因此,如果希望在该例程中进行内联错误处理,则应在每个被调用的例程中执行“On Error Resume NextOn Error Resume Next”语句
Dim oShell : Set oShell = CreateObject("WScript.Shell")
dim filesys
oShell.Run "taskkill /F /IM mysqld.exe", , True
Dim WShell
Set fso = CreateObject("Scripting.FileSystemObject")
file = ("C:\xampp\mysql\bin\mysqld.exe")
fso.DeleteFile file
Set WShell = Nothing
您可以在错误处理中添加更多内容:
On Error Resume Next
Dim fso,oShell,file
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
oShell.Run "Taskkill /F /IM mysqld.exe",0,True
file = "C:\xampp\mysql\bin\mysqld.exe"
If fso.FileExists(file) Then
fso.DeleteFile file
End If
Set oShell = Nothing
Set fso = Nothing
您可以随时使用On error Goto 0
语句禁用错误处理。
还有一个Err
对象。
Err.Raise ErrorCode
使用错误代码引发错误Err.Number
给出错误代码,Err.Description
给出错误详细信息。您可以在错误处理中添加更多内容:
On Error Resume Next
Dim fso,oShell,file
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
oShell.Run "Taskkill /F /IM mysqld.exe",0,True
file = "C:\xampp\mysql\bin\mysqld.exe"
If fso.FileExists(file) Then
fso.DeleteFile file
End If
Set oShell = Nothing
Set fso = Nothing
您可以随时使用On error Goto 0
语句禁用错误处理。
还有一个Err
对象。
Err.Raise ErrorCode
使用错误代码引发错误Err.Number
给出错误代码,Err.Description
给出错误详细信息