試試看這個VBScript中:
Option Explicit
Dim URL,acc
URL = "C:\Documents and Settings\Administrator\My Documents\Téléchargements\Vbscript.pdf"
Call IE_Run_PDF(URL) 'locally
'***************************************************
Sub IE_Run_PDF(URL)
Dim objShell,MaCmd,Titre,fso
Titre = "Run a PDF File with Internet Explorer"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(URL) Then
Set objShell = CreateObject("Wscript.Shell")
msgbox("iexplore.exe " & DblQuote(URL)),VbInformation,Titre
MaCmd = "iexplore.exe "& DblQuote(URL) &""
objShell.Run(MaCmd)
Else
MsgBox "The File " & DblQuote(URL) &" Dosen't Exists !",VbCritical,Titre
End If
End Sub
'***************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'***************************************************
URL = "http://repository.root-me.org/Programmation/VB/"
acc = "FR%20-%20Le%20language%20VBScript.pdf"
Call IE_Run_Net(URL,acc) 'Run on internet
'***************************************************
Sub IE_Run_Net(URL,acc)
Dim oIE1
Set oIE1 = WScript.CreateObject("InternetExplorer.Application")
oIE1.Navigate(URL & acc)
oIE1.Visible = 1
oIE1.AddressBar = 0
oIE1.StatusBar = 0
oIE1.ToolBar = 0
oIE1.MenuBar = 0
End Sub
感謝您回覆,但這並沒有解決這個問題。 當我使用批處理文件時,預期的操作可以正常工作,並在IE中打開PDF。但是當我使用VB腳本時,我使用原始問題中的代碼獲得了打開/保存/取消提示。我想在vb腳本級別避免這種情況,這樣我就不必修改其他瀏覽器來支持此腳本。 乾杯! – user3535998
如何在批處理文件中啓動PDF? – Bond