在任何主机上的批处理文件中解析USB驱动器号 [英] Resolve usb drive letter in batch file on any host computer

查看:92
本文介绍了在任何主机上的批处理文件中解析USB驱动器号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究了问题的可能解决方案,但恐怕我的知识水平不允许我正确提出问题.

I looked at the possible solutions for my question, but am afraid my knowledge level doesn't permit me to ask the question correctly.

我的USB驱动器名为CRUISER,我希望通过主机上的批处理文件运行几个应用程序.由于我不知道驱动器号是什么,如何在批处理文件中按名称解析驱动器?

My USB drive is named CRUISER, and I have a couple apps that I wish to run, via a batch file on the host computer. Since I have no idea what the drive letter will be how can I resolve the drive by name in a batch file?

这是我当前的主机端批处理文件中的内容. (正如您通过REM和pause语句所看到的,我已经在测试....)

Here is what I have in my current host side batch file. (as you can see by the REM and pause statements, I've been testing....)

REM Start Portable Apps and Signup Shield Suite
cd C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Temp\SignupShield\
del signupshieldportable.exe
REM dir
REM pause
cd \
%CRUISER%
REM dir
REM pause
start StartPortableApps.exe
cd PortableApps
REM dir
REM pause
start SignupShieldPortable.exe
rem pause

我要做的就是插入主机上的驱动器,运行基于主机的批处理文件,不管分配的驱动器号如何,让它找到我的CRUISER驱动器,然后运行这两个应用程序.我知道我可以将批处理文件放在USB驱动器上,并从那里运行它.现在,这只是我需要解决的挑战!

All I want to do, is plug in the drive on my host, run the host based batch file, and have it find my CRUISER drive, regardless of the assigned drive letter, and run the two apps. I know I can put the batch file on the USB drive and run it from there as I have done this. Now it is just a challenge I need to resolve!

感谢您的帮助

推荐答案

cruiser.txt放在USB驱动器的根目录中,并使用以下代码:

Place cruiser.txt in the root of the usb drive and use this code:

@echo off
for %%a in (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:\cruiser.txt" set "drv=%%a:"

这篇关于在任何主机上的批处理文件中解析USB驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆