Bilou_Gateux Posted February 2, 2006 Posted February 2, 2006 I need to find out the keystring of my WLAN NIC using a batch query, as I believe this changes on each install. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\13]"ServiceName"="{65FA9572-A7DB-42EE-8EC5-1D1D41E299FA}""Description"="Intel(R) PRO/Wireless 2200BG Network Connection"So I need a batch that search for Description "Intel® PRO/Wireless 2200BG Network Connection" in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\XX and then return the ServiceName value ({65FA9572-A7DB-42EE-8EC5-1D1D41E299FA}).Please help me out here! Ive really tried myself but cant figure it out. Yzöwl, I know you know this hehe care to help out? @ECHO OFFSETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION:// Set the description of NIC to find ServiceNameSET NIC="Intel(R) PRO/Wireless 2200BG Network Connection"for /F "tokens=7 delims=\" %%I in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards" ') do call :NIC %%IGOTO :EOF:NIC:// 3 tokens are ValueName Type Value under selected Key:// delims is a tab delimiterfor /F "tokens=3 delims= " %%I in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\%1" /v "Description" ^| findstr "REG_SZ" ') do set Description="%%I"for /F "tokens=3 delims= " %%J in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\%1" /v "ServiceName" ^| findstr "REG_SZ" ') do set ServiceName="%%J"IF %description%==%NIC% echo.%ServiceName%:EOFYzöwl, your welcome to rewrite it better, you are MSFN batch expert.
Yzöwl Posted February 2, 2006 Posted February 2, 2006 (edited) firstly Bilou, lets look at the wmic methods from earlier in the thread...Try this@ECHO OFFSETLOCAL ENABLEEXTENSIONSFOR /F "USEBACKQ SKIP=1" %%? IN ( `WMIC NICCONFIG WHERE "MACADDRESS='00:0E:35:2C:20:A7'" GET SETTINGID ^2^>NUL` ) DO ( IF ERRORLEVEL 0 SET SVCNAME=%%? )IF DEFINED SVCNAME ECHO/%SVCNAME%ENDLOCALGOTO :EOFor using the description@ECHO OFFSETLOCAL ENABLEEXTENSIONSFOR /F "USEBACKQ SKIP=1" %%? IN ( `WMIC NICCONFIG WHERE "DESCRIPTION='Intel(R) PRO/Wireless 2200BG Network Connection'" GET SETTINGID ^2^>NUL` ) DO ( IF ERRORLEVEL 0 SET SVCNAME=%%? )IF DEFINED SVCNAME ECHO/%SVCNAME%ENDLOCALGOTO :EOF<Edit>Bilou, I nearly forgot@ECHO OFF &SETLOCAL ENABLEEXTENSIONS:: Set the description of NIC to find ServiceNameSET "NIC=Intel(R) PRO/Wireless 2200BG Network Connection"FOR /F "DELIMS=" %%? IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards" ^|FINDSTR \\[0-9]*$ ^2^>NUL') DO IF ERRORLEVEL 0 CALL :NIC "%%?"IF DEFINED SvcName (ECHO/%SvcName% &PING -n 11 127.0.0.1 >NUL)ENDLOCAL &GOTO :EOF:NICREG QUERY "%~1" /v "Description" |FINDSTR/I "%NIC%" >NUL 2>&1 ||GOTO :EOF:: 3 tokens are Name Type and Data under selected Key:: delims is a tab delimiterFOR /F "SKIP=1 TOKENS=3 DELIMS= " %%? IN ('REG QUERY "%~1" /v "ServiceName" ^2^>NUL') DO IF ERRORLEVEL 0 SET SvcName=%%?GOTO :EOF</Edit> Edited February 2, 2006 by Yzöwl
BoardBabe Posted February 3, 2006 Author Posted February 3, 2006 Yzöwl: Did'nt we determine that the WHERE statement did not work (bug)?
RogueSpear Posted February 3, 2006 Posted February 3, 2006 I think WHERE is a valid command. I'm not all that familiar with using WMIC, but that's mainly because I access WMI through VBscript rather than through command. What I can say is that WHERE is integral to WMI construct.
BoardBabe Posted February 3, 2006 Author Posted February 3, 2006 Yes, but I'm pretty sure we determined there was a bug in that release hmm just can't recall what the bug was. I'm pretty sure it was the WHERE statement.
monstersnatch Posted February 3, 2006 Posted February 3, 2006 Study WMIC, it is really awesome command...hi, is there a way to set registry keys using wmic?! one can do really amazing stuff with the wmic commands, but i don't find a possibility to edit/create/delete reg.keys.. maybe someone could help me.thx in advancewould appreciate some attention anyone?!
Yzöwl Posted February 3, 2006 Posted February 3, 2006 If as you have already statedWMIC NicConfig Where Description="Intel(R) PRO /Wireless 2200BG Network Connection - Miniport for pakkeplanlegger" GET MTUworks, then there's is no problem with WHERE!is this line correct?WMIC NicConfig Where MACAddress="00:0E:35:2C:20:A7" Set SetMTU = 1500Now look at mineWMIC NICCONFIG WHERE MACADDRESS="00:0E:35:2C:20:A7" CALL SETMTU 1500there's no space=space before the MTU value.
Bilou_Gateux Posted February 3, 2006 Posted February 3, 2006 firstly Bilou, lets look at the wmic methods from earlier in the thread...Bilou, I nearly forgot Thanks for the optimized code. I learn the best ways to code from your postings. About wmic, i can only use it one my full Windows install.On my Windows XP Embedded runtime image, WMI Command Line Utility isn't added.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now