从 CD 运行批处理到 EXE 的问题
作为一个恩惠,我正在将一些视频制作成 DVD。它们都是不同的分辨率、编解码器和容器。为了节省时间,我想我只需捆绑 MPC 并使用批处理脚本启动它们即可。我被告知他们需要一个图标,因为据我所知,无法使用 %CD%
在 Windows 中创建动态快捷方式。 非常简单的批处理脚本:
START "" "%cd%\MPC-HC\mpc-hc.exe" "%cd%\VideoFiles\01.mp4"
所以我尝试了一些 BAT 到 EXE 应用程序,发现它们实际上只是解压缩 BAT 并运行它。他们使用 %CD%
作为临时文件夹,这使得无法从光盘启动。
所以我找到了 ExeScript 并且我可以更改临时目录...唯一的问题是什么?然后 BAT 从那里启动,这意味着 %CD%
毫无用处。
因此,我再次更改批处理文件来嗅探光盘驱动器:
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\01.exe
set rundir=%%a:
START "" "%rundir%\MPC-HC\mpc-hc.exe" "%rundir%\VideoFiles\01.mp4"
这工作得足够好(如果光盘托盘打开或为空,则会导致错误),但是如果将文件复制到 HDD,则情况并非如此。将尝试从 CD 中读取。无法知道它是从硬盘驱动器还是从光盘启动。
在这一点上,我什至希望获得有关如何用 C 编写类似内容并避免使用批处理文件(从而避免临时文件混乱)的帮助。
As a favour, I'm compiling a number of videos on a DVD. They're all different resolutions, codecs and containers. To save myself sometime I thought I'd just bundle in MPC and have a batch script launch them. I was told they need an icon and since there's no way to make dynamic shortcuts in Windows using %CD%
, as far as I could find.
Very simple batch script:
START "" "%cd%\MPC-HC\mpc-hc.exe" "%cd%\VideoFiles\01.mp4"
So I've tried a few BAT to EXE apps and found that they really just decompress the BAT and run it. They use %CD%
as their temp folder which makes it impossible to launch from a disc.
So I found ExeScript and I can alter the temp directory... Only problem? The BAT then launches from there then, meaning%CD%
is useless.
So once again I alter the batch file to sniff out the disc drive:
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\01.exe
set rundir=%%a:
START "" "%rundir%\MPC-HC\mpc-hc.exe" "%rundir%\VideoFiles\01.mp4"
This works well enough (causes an error if disc trays are open or empty), however if the files are copied to the HDD, then it doesn't as it'll try to read from the CD. There's no way of knowing if it's being launched from a hard drive or disc.
At this point I'd even appreciate help on how to write something like this in C and avoid batch files all together (and thus the temp file mess).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过安装一个来自驱动器的版本和一个来自硬盘驱动器的版本解决了这个问题。最简单的解决方案。
I've solved this by putting on a version for from the drive and one for from the HDD. Easiest solution.
相对文件夹路径怎么样?
这应该同样适用于 HDD 和 CD。
What about relative folder paths?
That should work on HDD and CD alike.