2013-04-16 32 views
0

正確的即時通訊尋找一個腳本,我可以點擊後,我已登錄打開各種程序,只是爲了節省我一點時間。我設法得到一個腳本來打開一個,但作爲一個新手可以有人提供建議。VB腳本一次打開多個程序

Dim objShell 
Set objShell = WScript.CreateObject("WScript.Shell") 
objShell.Run """C:\Program Files (x86)\servicecenter\Run\scguiw32.exe "" ""- 

express:dvla.servicecenter.fs.fujitsu.com.12680""" 
Set objShell = Nothing 

回答

0

我沒有scguiw32.exe,所以我創建了簡單的腳本,它在記事本和單詞中打開文件。

Dim objShell 
Set objShell = WScript.CreateObject("WScript.Shell") 
objShell.Run "C:\Windows\notepad.exe c:\dump.txt" 

objShell.Run """C:\Program Files (x86)\Microsoft Office\Office14\winword.exe"" c:\dump.txt" 
Set objShell = Nothing 

順便說一句,現在你可以使用powershell而不是vbscript,而powershell腳本更容易理解。例如上面一會:與內容創建run.ps1

& 'C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE' c:\dump.txt 
notepad.exe C:\dump.txt 

點擊使用PowerShell右鍵單擊它並選擇Run

+0

凡有dump.txts文件來自 –

+0

Dump.txt只是傳遞給EXE文件 –

+0

你將能夠爲基礎的powershell腳本上我寫的這個問題爭論的例子? –

0

這裏是如何使用VBScript來創建你想要運行的程序的數組然後執行每一個。

'---Declare Variables 
Dim objShell, strprogram1, strProgram2, colprograms, item 

'---Create Scripting Shell Object 
Set objShell = CreateObject("WScript.Shell") 

'---Create Program Variables 
strProgram1 = """C:\Program Files (x86)\servicecenter\Run\scguiw32.exe"" ""-express:dvla.servicecenter.fs.fujitsu.com.12680""" 
strProgram2 = "C:\Windows\notepad.exe C:\Dump.txt" 

'---Add Variables to an Array 
colPrograms = Array(strProgram1,strProgram2) 

'---Run each program in the array once 
For Each item In colprograms 
    objShell.Run item 
Next 

WScript.Echo "Done." 
1

對於這項工作,您可能會過度使用VBScript或Powershell。批處理文件將起作用。

@echo off 
start "c:\Program Files\Folder 1\program.exe" 
start "c:\Program Files\Folder 2\program.exe" -switch -argument 
exit 
0
Dim objShell 
Set objShell = WScript.CreateObject("WScript.Shell") 
objShell.Run("Path to program") 
wscript.sleep (100) 
objShell.Run("Path to program") 
wscript.sleep (100) 
wscript.quit