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. 如何从.bat运行.vbs
- 2. 如何从Python运行vbs?
- 3. 如何在VBS中使用文件名
- 4. 从C#运行vbs子文件#
- 5. 我们应该使用CScript.exe还是WScript.exe运行.vbs文件?
- 6. 如何从Microsoft脚本编辑器内运行.vbs文件?
- 7. 使用cmd运行vbs脚本
- 8. 如何使用VBS
- 9. 从.bat运行.vbs?
- 10. 如何从cmd运行VBS脚本?
- 11. 如何在Internet Explorer中运行vbs
- 12. 无法从jenkins运行.vbs文件,该文件有excel脚本
- 13. 如何使用editplus运行jar文件
- 14. 如何使用VBScript运行RDP文件?
- 15. 如何使用Java运行Perl文件?
- 16. 如何使用Python运行文件?
- 17. 如何使用AutoIT运行bat文件?
- 18. 如何使用smb运行文件
- 19. 如何使用VBS垃圾邮件
- 20. 尝试运行VBS脚本
- 21. 从vbs运行exe错误
- 22. 从VBS文件
- 23. VBS如果文件打开
- 24. 如何使用通配符部分搜索文件在VBS
- 25. 如何使用批处理创建一个vbs文件
- 26. 用VBS下载文件
- 27. VBS文件保存为UTF-8不运行
- 28. 从VB宏(.vbs)运行批处理(.bat)文件
- 29. 从SQL Server运行.vbs文件(SSMS 2012或2014)
- 30. 如何从R运行VBS脚本,同时将参数从R传递给VBS
@YourComputerHelpZ - 你是一个让很多伟大的答案。也许你应该解释你的目标是什么。打开'file.bat'然后做什么?在消息框中显示其内容,编辑一些文本,运行批处理文件等? – ichiban 2009-06-05 15:26:25
通过说“开放”,你的意思是“启动”/“执行”? – Helen 2009-06-05 15:40:25
是的,我想运行它。 – 2009-06-05 15:41:01