1)Pipe the output to the FINDSTR command to isolate the Instance ID.
2) Capture that command output with a FOR /F command like you have done in other batch files.
3) Run the command to remove the device with that output.
Make an attempt.
Search found 4314 matches
- 22 Dec 2023 17:00
- Forum: DOS Batch Forum
- Topic: identify all instance id's in output of pnputil and then sends remove-device command for each
- Replies: 1
- Views: 5425
- 20 Dec 2023 10:53
- Forum: DOS Batch Forum
- Topic: Batch file to replace - with . in file name
- Replies: 6
- Views: 17287
Re: Batch file to replace - with . in file name
@echo off cd /d "%~dp0" for /f "delims=" %%i in ('dir /b /s /a-d *-*.pdf') do ( set "OldFile=%%i" set "OldName=%%~nxi" setlocal enabledelayedexpansion set NewName=!OldName:- Deposit=TALLY! set NewName=!NewName:-=.! ren "!OldFile!" "!NewName!" endlocal ) pause You should just change your name to Bat...
- 19 Dec 2023 22:17
- Forum: DOS Batch Forum
- Topic: Replace Word In Filename With Another Word
- Replies: 3
- Views: 5537
Re: Replace Word In Filename With Another Word
Again this is basic string substitution. Your last two forum threads covered both of what you want to do. What don't you understand?
- 18 Dec 2023 18:46
- Forum: DOS Batch Forum
- Topic: if statement or if satement
- Replies: 4
- Views: 6301
Re: if statement or if satement
When you read the help file for the IF command where did it show usage for using a PIPE or OR?
- 17 Dec 2023 19:06
- Forum: DOS Batch Forum
- Topic: Batch file to delete .inf files from a ADMIN CMDprompt.
- Replies: 7
- Views: 10804
Re: Batch file to delete .inf files from a ADMIN CMDprompt.
Your code is just echoing to the screen what the pnputil execution would do.
- 16 Dec 2023 21:57
- Forum: DOS Batch Forum
- Topic: How to make an underscore variable "-----" with the length of the argument variable?
- Replies: 5
- Views: 8220
Re: How to make an underscore variable "-----" with the length of the argument variable?
“If you give a man a fish, you feed him for a day. If you teach a man to fish, you feed him for a lifetime.”
- 15 Dec 2023 12:13
- Forum: DOS Batch Forum
- Topic: How to make an underscore variable "-----" with the length of the argument variable?
- Replies: 5
- Views: 8220
Re: How to make an underscore variable "-----" with the length of the argument variable?
Start by using the String Length function from the Dostips Library. https://www.dostips.com/DtTipsStringOperations.php#Function.strLen Then you have a few options from there. You could use a for /l loop to build the underscore variable to the correct length. You could also have a predefined undersco...
- 05 Dec 2023 12:49
- Forum: DOS Batch Forum
- Topic: Copy cmd window and write to .txt
- Replies: 2
- Views: 18056
Re: Copy cmd window and write to .txt
You were told 7 years ago by the now deceased Foxidrive on alt.msdos.batch.nt that those programs output as unicode. And Foxidrive showed you how to use the TYPE command to translate them back to ASCII.
- 05 Dec 2023 12:38
- Forum: DOS Batch Forum
- Topic: dism.exe isn't running.
- Replies: 6
- Views: 23281
Re: dism.exe isn't running.
And you have been warned about not using quotes with IF comparisons at least twice previously.
viewtopic.php?f=3&t=10778&p=68385#p68387
viewtopic.php?f=3&t=9397&p=60988#p60991
viewtopic.php?f=3&t=10778&p=68385#p68387
viewtopic.php?f=3&t=9397&p=60988#p60991
- 05 Dec 2023 12:26
- Forum: DOS Batch Forum
- Topic: dism.exe isn't running.
- Replies: 6
- Views: 23281
Re: dism.exe isn't running.
Thank you both for the reply... That solved that problem. I have run into another problem that I can't figure out. C:\>C:\Batch\SetACL.exe -on "C:\Temp" -ot folder -actn ace "n:Win10BootRepair\Gary;p:full" ERROR in command line: Invalid object type specified: folder! Like when you posted this same ...
- 05 Dec 2023 12:11
- Forum: DOS Batch Forum
- Topic: My syntax is not correct
- Replies: 3
- Views: 13666
Re: My syntax is not correct
Thank you very much. That's great to know. It's very nice of you to share your knowledge. Straight from the help file for the findstr command. Use spaces to separate multiple search strings unless the argument is prefixed with /C. I have seen a pattern with some of your questions and it seems like ...
- 05 Dec 2023 11:59
- Forum: DOS Batch Forum
- Topic: Batch file to replace - with . in file name
- Replies: 6
- Views: 17287
Re: Batch file to replace - with . in file name
Anyone know how to make a batch file to replace all dashes (-) in a file name with periods (.)? I basically have a ton of PDF files that are named like this: HN TALLY 11-18-23.pdf HN TALLY 11-19-23.pdf REG 11-20-23.pdf EW CAR 11-21-23.pdf and so on.... I would like it to rename the files like this ...
- 22 Nov 2023 20:39
- Forum: DOS Batch Forum
- Topic: Change to upper case and add a :
- Replies: 4
- Views: 18753
Re: Change to upper case and add a :
I would like to make sure the input letter is upper case and I would like to add a : the code below doesn't add the colin. setlocal EnableDelayedExpansion set /p Drive=Please enter drive letter. Example C call :Uppercase Drive set "colin = :" set "Drive &= %colin%" Echo %Drive% cmd /k You cannot be...
- 16 Nov 2023 11:38
- Forum: DOS Batch Forum
- Topic: [Solved] Need help to convert single line xml file to sequential line
- Replies: 7
- Views: 22399
Re: Need help to convert single line xml file to sequential line
This should get you started. https://stackoverflow.com/questions/33077104/batch-script-for-formatting-xml-files-search-for-strings-and-comment-them-out Hey thanks, but this doesn't skip the first 2 tags and I don't want it to be format like this <xml> <tag> <othertag> </othertag> </tag> </xml> Wasn...
- 10 Nov 2023 15:59
- Forum: DOS Batch Forum
- Topic: Problems working a script
- Replies: 6
- Views: 21154