Board logo

标题: [已结] vbs脚本如何打开windows临时目录并打开指定文件呢 [打印本页]

作者: cichulai     时间: 2009-2-16 18:13    标题: [已结] vbs脚本如何打开windows临时目录并打开指定文件呢

如题!

[ Last edited by cichulai on 2009-2-18 at 03:59 ]
作者: newxso     时间: 2009-2-17 00:56

Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
WshShell.Exec "explorer.exe ""%temp%"""
WshShell.Run "cmd.exe /c start """" ""%temp%\a.txt""",0 ,true
Set WshShell = Nothing
(RE:5楼)

知道了目录,后面加上路径及文件名就可以(以楼下everest79兄的代码为例):
Dim WshShell
Set WshShell=CreateObject("WScript.Shell")
Set WshEnvP=WshShell.Environment("Process")
strFolder=WshEnvP("TEMP")
WshShell.Run strFolder
WshShell.Run strFolder & "\1.txt"


[ Last edited by newxso on 2009-2-18 at 10:32 ]
作者: everest79     时间: 2009-2-17 02:42

Dim WshShell
Set WshShell=CreateObject("WScript.Shell")
Set WshEnvP=WshShell.Environment("Process")
WshShell.Run WshEnvP("TEMP")

作者: cichulai     时间: 2009-2-17 14:08
谢谢newxso;everest792位的热心帮助
作者: cichulai     时间: 2009-2-17 14:10
everest79请问你的脚本怎么打开临时文件的指定文件呢 比如说临时文件下的1.txt
再次麻烦了
作者: HAT     时间: 2009-2-17 14:18    标题: Re 4楼

如果有人帮你解决了问题,建议进行以下操作:

1、修改帖子标题,在标题最前面注明:[已结]

2、给正确回答问题者加分以示感谢,虽然大家来论坛是为了学习而不是为了积分,但加分聊表谢意总是或多或少能够让花费了时间和精力无私帮助你的人略感欣慰。

3、如果你是在别人的提示下自己写出了代码,请把自己的方法贴出来跟大家分享一下,也许他人可以帮你指出代码中的不足之处、告诉你如何提高执行效率等,有交流才能更快地进步。