工具——Windows下使用vbs脚本打开文件夹或软件

Windows下使用vbs脚本打开文件夹或软件


打开文件夹:

1、在“C:\my_script”目录下创建open_dir.vbs脚本文件:

Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.Arguments(0)
strPath = "explorer.exe /e," & strPath
objShell.Run strPath

其中,“Set objShell = CreateObject("Wscript.Shell")”行表示打开一个窗口; “strPath = "explorer.exe /e," & strPath”行表示:以资源浏览器的方式打开文件夹;


2、在在该目录下创建open_dir.bat批处理文件:

cd C:\my_script
open_dir.vbs "D:\Shared_Dir\ShareDir"
open_dir.vbs "E:\Proj_Code\SVN\C15"

其中,open_dir.vbs "D:\Shared_Dir\ShareDir"行中后面的参数路径"D:\Shared_Dir\ShareDir"会传递给上面的“strPath”,并且应该是绝对路径;


打开软件:

创建open_software.vbs文件:

'open working software

Program1 = "D:\Soft_Pro\fm70chb1_92_chs\Foxmail.exe"  
Program2 = "D:\Soft_Pro\imo\i'm office\IMOClient.exe"

Set WshShell=createobject("wscript.shell")
Set oExec=WshShell.Exec(Program1)
Set WshShell=createobject("wscript.shell")
Set oExec=WshShell.Exec(Program2)


其中,Program1是所要打开的软件的 绝对路径;Set WshShell=createobject("wscript.shell")和Set oExec=WshShell.Exec(Program1)行表示在新建的窗口中执行打开一个路径为(Program1)的软件的命令;


附:vbs脚本中的注释符号 (’),如上例中的  'open working software;

你可能感兴趣的:(日常问题,.,常用配置文件与使用,技术原理,.,Windows相关)