1条回答 默认 最新
- threenewbee 2019-08-16 00:11关注
stackoverflow上有人给出一个办法
编写一个vbs
set WshShell = WScript.CreateObject("WScript.Shell") set WMIService = GetObject("winmgmts:root\cimv2") dim FirstCommandLine, CommandLineParts, AllFiles set AllInstances1 = WMIService.ExecQuery("Select CommandLine FROM Win32_Process WHERE CommandLine LIKE '%" & wscript.scriptname & "%'") For Each item In AllInstances1 FirstCommandLine = item.CommandLine 'Get the command line of the first instance of this script exit for Next if InStr(FirstCommandLine,WScript.Arguments.Unnamed(0)) then 'This is the first instance WScript.Sleep 400 'Update instance list to check if other instances appeared set AllInstances2 = WMIService.ExecQuery("Select CommandLine FROM Win32_Process WHERE CommandLine LIKE '%" & wscript.scriptname & "%'") while AllInstances2.count > AllInstances1.count 'While other instances keep appearing WScript.Sleep 400 'Keep updating instance list set AllInstances1 = AllInstances2 set AllInstances2 = WMIService.ExecQuery("Select CommandLine FROM Win32_Process WHERE CommandLine LIKE '%" & wscript.scriptname & "%'") wend For Each item In AllInstances2 CommandLineParts = Split(item.CommandLine,"""") AllFiles = AllFiles & """" & CommandLineParts(UBound(CommandLineParts)-1) & """ " 'Get all the file paths Next WshShell.Run("""Path\to your\application.exe"" /switches" & AllFiles) '这里是你实际要调用的用来打开文件的VB程序。用Command语句和Split得到文件 else 'This is not the first instance. Before exiting, sleep for a moment for the first one to detect. WScript.Sleep 4000 end if
注册表中 wscript //nologo "Full Path\myscript.vbs" "%1" 作为命令行(Full Path\myscript.vbs是这个脚本的路径)
这里还有一个基于消息通讯的
https://stackoverflow.com/questions/21062046/open-multiple-files-via-shell-context-menu-as-params
不过是delphi写的,思路我看了下,VB应该也可以实现。解决 无用评论 打赏 举报
悬赏问题
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记
- ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作