[英]VBS Path Error Handling
在過去的幾個月中,我一直遇到問題,因為此VBScript在每台計算機上均無法100%正常工作。 似乎是某些Windows 10和Windows 7 Ultimate出現了問題。
我一直在使用其他VBScript的變通辦法,其中更改了\\DATA
,而只是\\DATA
DATA
。 我一直在嘗試使用錯誤處理來忽略問題並運行其他版本的代碼,但是即使使用On Error Resume Next
或Try Catch Finally
語句,我仍然會彈出找不到文件的提示。 我還嘗試了On Error GoTo
錯誤處理。
如何使它嘗試更改路徑,而不回退任何錯誤消息,然后轉到下一個路徑選項?
Set shell = CreateObject("Shell.Application")
Dim WshShell, InPath
Set WshShell = WScript.CreateObject("WScript.Shell")
InPath = WshShell.CurrentDirectory + "\DATA"
'shell.ShellExecute "application", "arguments", "path", "verb", window
shell.ShellExecute "Install.bat", , InPath, "runas", 1
Set shell = Nothing
可能還有另一種解決方法。
檢查路徑,如果不存在,請與其他路徑一起使用。 查看評論。
Dim fso, InPath
Set fso = CreateObject("Scripting.FileSystemObject")
'Get the path
InPath=WshShell.CurrentDirectory +"\DATA"
exists = fso.FolderExists(InPath)
'Check if not exists, replace with other path
If Not(exists) Then
InPath=WshShell.CurrentDirectory +"DATA"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.