开发者

Vendor ID grabber writ in win batch not working right on vista

Ok. I'll make the boring stuff quick...my specialty is with electronic hardware troubleshooting, but I am proficient with windows and linux. I开发者_开发知识库 have developed a taste for writing useful win batch files. Please dont try to upsell other forms of code (C++, etc), as I am incapable of writing anything outside batch, bash, and the occasional light vb script.

So, I started a little batch that uses DEVCON to fetch device instance ID's, and cross reference them to a local database, for unknown device identification.

What is happening is that the ">" output to text is messing up, and as far as I can tell, is because of the UAC in vista and 7. It works when I run the script as an admin, but doesn't output to the right areas (since its working from sys32 folder), and I can't hardcode the usb jump drive letter, because it will vary from PC to PC.

The script is on removable media, and SUPPOSED to write out to the jump drive it is on. When it gets to a ">" and not run as admin, it runs it in a new command window, and doesn't output. How can I get this localized?

Heres the troublesome area:

[NOTE: ini files that FOR searches are like this:]

[venid.ini] devid=8086=Intel Corporation

[devid.ini] devid=4229=WiFi Link 4965AG

:idlookup
set dd=Unknown

set /P VENID=Enter Vendor ID: %=%
echo %venid%>> searches.txt
for /f "tokens=1,2,3,4 delims==" %%a in (venid.ini) do (
if %%b==%venID% set VS=%%c
if %%b==%venID% set vd=%%b
)

REM echo  Searching local machine...
REM devcon -m:\\%computername% find *ven_%venid%* > foundids.txt
REM foundids.txt

REM set /P DEVID=Enter Device ID: %=%
REM for /f "tokens=1,2,3,4 delims==" %%a in (devid.ini) do (

REM if %%b==%DEVID% set dd=%%c
REM )

REM echo       VendorID:  %VD%
echo          Vendor: %VS%
REM echo  Device ID:   [%DEVID%]
REM echo  Description: [%DD%]
pause
set VS=Unknown
goto :vidmenu


You could try using %~dp0 to get the absolute path of the directory containing the batch file, then base your output file location relative to that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜