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 如何让企业微信机器人实现消息汇总整合
- ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
- ¥15 如何用Python爬取各高校教师公开的教育和工作经历
- ¥15 TLE9879QXA40 电机驱动
- ¥20 对于工程问题的非线性数学模型进行线性化
- ¥15 Mirare PLUS 进行密钥认证?(详解)
- ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
- ¥20 想用ollama做一个自己的AI数据库
- ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
- ¥15 请问怎么才能复现这样的图呀