0

こんにちは、vbscript を使用してさまざまなインターネット ページやプログラムを開くスクリプトを作成しようとしていますが、ネットワーク ドライブにある PDF ファイルを開くのに苦労しています。一連のコマンドを試しましたが、ファイルを開くことができません。まったく、どんな助けでも大歓迎です:)

Set IE = CreateObject("InternetExplorer.Application") 
set WshShell = WScript.CreateObject("WScript.Shell")  
IE.Navigate "https://websiteaddress.com
IE.Visible = True 
Wscript.Sleep 3000 
WshShell.SendKeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "text"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "{TAB}"
WshShell.Sendkeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.SendKeys "%{TAB}"
WshShell.SendKeys "%{F4}"
Wscript.Sleep 3000
WshShell.SendKeys "%{TAB}"
IE.Navigate "https://websiteaddress.com"
IE.Visible = True 
Wscript.Sleep 3000
WshShell.SendKeys "text"
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 3000
WshShell.Run "H:\Shortcuts /k dir *.*"
WshShell.Run "Notepad.exe"
Wscript.Sleep 3000
WshShell.Run "calc.exe"

私はvbscriptingに非常に慣れていませんが、次の2行を試しましたが、どちらも機能しません。

WshShell.Run "G:\pathtofile\thepdf.pdf"

WshShell.Run "NET USE G: \\server\share\thepdf.pdf"
4

1 に答える 1

2

あなたが vbscript に慣れていないにもかかわらず、そのようなことを行うためにその言語を選択したことに驚きました。vbscript はこの種の作業にはあまり適しておらず、vbscript の日数はカウントされます。プログラム言語を使用する場合は、Ruby の方が適しています。物事を自動化したいだけなら、http://www.autohotkey.com/を使用することをお勧めします

とにかく、このように vbscript で動作するはずです。"" は、文字列内の単一の " を表します。

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """g:\path with spaces\thepdf.pdf"""
于 2012-06-25T21:49:28.743 に答える