如何将单击的文件完整路径传递到设置为默认程序以打开某些特定文件类型的批处理命令快捷方式
我有一个批处理命令(设置为打开所有图像文件的默认程序),运行以下命令
rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1
这可能会打开 Windows 图片查看器
现在在%1 我必须传递所需的图片,该图片肯定可以从 Windows UI 访问。但我如何告诉它应该打开哪个文件?如何在批处理命令的参数中传递双击文件的完整路径,是否没有任何环境变量保存上次访问的文件的完整路径?
I have a batch command (set as the default program to open all image files) that runs the following command
rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1
this is suppose to open windows picture viewer perhaps
Now in the %1 i have to pass the desired picture which is surely accessed from windows UI. But how will i tell it which file is it suppose to open ? How do i pass the double clicked file's full path in the parameter of the batch command, is not there any environment variable that holds the last accessed file's full path ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不会。批处理文件存在此问题,但可以避免,因为传递的参数包括特定文件的完整路径。但是,如果完整路径名(将!)包含空格,则必须将参数括在引号中以避免出现任何错误:
另一方面,您也可以将多个文件名拖放到批处理文件中。在这种情况下,您必须通过带有 SHIFT 命令的循环以通常的方式处理它们:
No. Batch files have this problem, but it is avoided because the passed parameter includes the full path to the particular file. You must, however, enclose the parameter in quotes to avoid any error if the full path name would (will!) include spaces:
On the other hand, you may also drag-and-drop several file names to your Batch file. In this case, you must process they in the usual way via a loop with a SHIFT command: