7
A
回答
18
是的,我想運行它。
那就試試這個:
CreateObject("WScript.Shell").Run "file.bat"
0
查看technet上的許多示例Script Center Script Repository。
一個簡單的例子是Select and Ping Computers Using a Text File:
On Error Resume Next
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\servers.txt", ForReading)
strComputers = objTextFile.ReadAll
objTextFile.Close
arrComputers = Split(strComputers, vbCrLf)
Set objShell = CreateObject("WScript.Shell")
For Each strComputer In arrComputers
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer
Set objExecObject = objShell.Exec(strCommand)
strText = objExecObject.StdOut.ReadAll
If Instr(strText, "Reply") > 0 Then
' =====================================================================
' Insert your code here
' =====================================================================
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_OperatingSystem")
For Each objItem In ColItems
Wscript.Echo strComputer & ": " & objItem.Caption
Next
Else
Wscript.Echo strComputer & " could not be reached."
End If
Next
+0
嗯..不能真正找到我要找的東西。 – 2009-06-05 15:12:21
+0
我需要打開批次 – 2009-06-05 15:18:11
+0
第一個答案是最好的 – RookieTEC9 2015-08-11 15:49:35
0
使用打開文件:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(".\File.bat", ForReading)
0
function getFileInfo(filePath)
dim fso, fileObj, outMsg
set fso = createobject("Scripting.FileSystemObject")
set fileObj = fso.getfile(filePath)
outMsg = ""
outMsg = outMsg & " Created: " & fileObj.DateCreated & vbcrlf
outMsg = outMsg & " Last Accessed: " & fileObj.DateLastAccessed & vbcrlf
outMsg = outMsg & " Last Modified: " & fileObj.DateLastModified & vbcrlf
outMsg = outMsg & " File Type: " & fileObj.Type & vbcrlf
if fileObj.attributes and 0 then
outMsg = outMsg & " File Attributes: Normal File"
else
outMsg = outMsg & " File Attributes: "
if fileObj.attributes and 1 then
outMsg = outMsg & "Read Only "
end if
if fileObj.attributes and 2 then
outMsg= outMsg & "Hidden "
end if
if fileObj.attributes and 4 then
outMsg= outMsg & "System "
end if
if fileObj.attributes and 8 then
outMsg= outMsg & "Volume "
end if
if fileObj.attributes and 16 then
outMsg= outMsg & "Directory "
end if
if fileObj.attributes and 32 then
outMsg= outMsg & "Archive "
end if
if fileObj.attributes and 1024 then
outMsg= outMsg & "Link "
end if
if fileObj.attributes and 2048 then
outMsg= outMsg & "Compressed "
end if
end if
set fileObj = nothing
set fso = nothing
getFileInfo = outMsg
end function
-3
門套代碼:
jamb(run) "%PWD%\File.bat" & display box(small) with $OUTPUT
VBS代碼:
set runFile (".\file.bat")
mode console
msgbox (runFile)
相關問題
- 1. 如何在php中運行vbs文件
- 2. 如何從Python運行vbs?
- 3. 如何從.bat運行.vbs
- 4. 如何禁用運行vbs文件的Windows Script Host的ECHO DIALOGS?
- 5. 如何在VBS中使用文件名
- 6. 從批處理文件運行.VBS
- 7. 從C#運行vbs子文件#
- 8. VBS WScript.Shell運行.htm文件掛起IE
- 9. VBS在.bat上運行文件
- 10. 在asp.net中使用進程類運行.vbs腳本文件
- 11. 使用C#代碼運行vbs腳本文件
- 12. 我們應該使用CScript.exe還是WScript.exe運行.vbs文件?
- 13. 如何使用java編程從特定文件夾運行.bat或.vbs腳本
- 14. 如何從Microsoft腳本編輯器內運行.vbs文件?
- 15. 如何通過vbs運行.bat文件(路徑包含空間)
- 16. 如何使用VBS腳本從.ini文件中刪除一行
- 17. 使用Windows計劃程序運行.vbs文件(通過批處理文件?)
- 18. 使用cmd運行vbs腳本
- 19. 如何使用VBS
- 20. 如何運行一個外部的vbs文件特別excel文件
- 21. 如何在Internet Explorer中運行vbs
- 22. 如何從cmd運行VBS腳本?
- 23. 從.bat運行.vbs?
- 24. 運行VBS腳本
- 25. 使用.vbs文件打印html文件
- 26. 如何從vbs以管理員身份運行vbs?
- 27. 如何使用vbs計劃任務運行vb.net
- 28. 無法從jenkins運行.vbs文件,該文件有excel腳本
- 29. VBS文件通信/執行
- 30. 如何使用smb運行文件
@YourComputerHelpZ - 你是一個讓很多偉大的答案。也許你應該解釋你的目標是什麼。打開'file.bat'然後做什麼?在消息框中顯示其內容,編輯一些文本,運行批處理文件等? – ichiban 2009-06-05 15:26:25
通過說「開放」,你的意思是「啓動」/「執行」? – Helen 2009-06-05 15:40:25
是的,我想運行它。 – 2009-06-05 15:41:01