batch file automation for search, fill in results.
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 24

Thread: batch file automation for search, fill in results.

  1. #1
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051

    Exclamation batch file automation for search, fill in results.

    I'm working on a batch file to make a utility at the office and I'm stumped on one part.

    I want to automate the process stated below, preferrably within the confines of a batch file without using outside applications.

    1.
    Click Start > Search, type cmd, and press Ctrl+Shift+Enter to start a command prompt with Administrator privileges.

    2.
    Type pnputil -e to list the drivers in the driver store.

    3.
    Type pnputil -f -d oem<n>.inf to remove specific drivers from driver store, where <n> is a number corresponding to one of the specified drivers listed in the previous step.

    If this is too touchy a topic to post publicly, can someone please privately contact me on how to do this?
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  2. #2
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,493
    I'm not sure I understand what you want. If I did then I could help...
    You still have to list the drivers. Then choose one to remove.
    Maybe I just need another coffee...
    Protected by Glock. Don't mess with me!

  3. #3
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    the value changes per machine because of the order the drivers were installed/volume of drivers differs. I want it to be able to search out a driver name and the number and fill it in for the next command. I also am not familiar with making a batch file give itself admin rights.

    So the search part needs to do a wildcard search in the results such as oem15.inf the orange text being the wild card. I would assume oem*.inf would work but I still need to know how to get it to pick that out of the search results one associated with a specific vendor such as samsung or intel. If you try the command out in cmd you'll see what I'm looking at.
    Last edited by Niclo Iste; October 3rd, 2012 at 10:21 AM. Reason: more details
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  4. #4
    Super Moderator
    Join Date
    Jul 2012
    Location
    Severn, Maryland, USA
    Posts
    376
    Unfortunately a BATch file cannot "Click" anything.
    --
    Doc
    ___________Microsoft Safety & Security Center___________
    \____________________ ____.-.____ ____________________/
    \_____________\ -._)!(_.- /_____________/
    \_______\. ~\ /~ ./_______/
    \_______/

    "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Blaise Pascal

  5. #5
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    Quote Originally Posted by SpywareDr View Post
    Unfortunately a BATch file cannot "Click" anything.
    Fortunately windows is a GUI overlayed on a command prompt system. C++ which incidentally most of Windows is written in is used to create GUIs that can complete tasks that were written in a command line format.
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  6. #6
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,493
    So you mean something like:

    C:\>removedrivers samsung
    Driver remover utility
    ---------------------
    Found drivers:
    12 - Universal Serial Bus controllers ~ SAMSUNG Electronics Co., Ltd.
    18 - Ports (COM & LPT) ~ SAMSUNG Electronics Co., Ltd.
    Which one would you like to remove?
    >15
    Driver 15 is not on the list. Typo?
    Which one would you like to remove?
    >12
    oem12.inf removed successfully
    Bye Bye!
    Protected by Glock. Don't mess with me!

  7. #7
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    Not as picky, what I'm trying to create will remove all samsung or whatever vendor I choose.

    The thing is the number is not static and changes per machine so I can't just make a command to search out a specific number inf.
    Last edited by Niclo Iste; October 3rd, 2012 at 02:41 PM.
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  8. #8
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,493
    It's doable, but not necessarily easy. A batch file wouldn't be my choice, not even close. And honestly, with so many freebies out there why even bother?
    But I'll try to produce something just for hahas...
    Protected by Glock. Don't mess with me!

  9. #9
    Super Moderator
    Join Date
    Jul 2012
    Location
    Severn, Maryland, USA
    Posts
    376
    Quote Originally Posted by Niclo Iste View Post

    C++ which incidentally most of Windows is written in is used to create GUIs that can complete tasks that were written in a command line format.

    In your first post you stated ...

    Quote Originally Posted by Niclo Iste View Post

    I'm working on a batch file ...

    I want to automate the process stated below, preferrably within the confines of a batch file ...

    1. Click Start > Search, ...

    If the "batch file" is no longer a requirement, that changes everything.
    --
    Doc
    ___________Microsoft Safety & Security Center___________
    \____________________ ____.-.____ ____________________/
    \_____________\ -._)!(_.- /_____________/
    \_______\. ~\ /~ ./_______/
    \_______/

    "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Blaise Pascal

  10. #10
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    Quote Originally Posted by SpywareDr View Post
    In your first post you stated ...




    If the "batch file" is no longer a requirement, that changes everything.
    I'm noticing a trend here with your posts, despite CeeBee's input you are of the stance of "nothing can be done give up all hope". I'm not sure if it's because you think I'm some schmuck who hasn't been in the field for 13 years or if you're just angry at people in general. I've found your responses as of late to not be useful and I'm gladly putting your further posts on the ignore list. If you have nothing constructive to add to the thread feel free to not join in on it.
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  11. #11
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    Quote Originally Posted by CeeBee View Post
    It's doable, but not necessarily easy. A batch file wouldn't be my choice, not even close. And honestly, with so many freebies out there why even bother?
    But I'll try to produce something just for hahas...
    The reason I'm trying to isolate it to a batch and resources readily found in windows is because I have to push this through remotely to 100+ computers local and remotely connected to the office.

    Thanks for looking into this CeeBee.
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  12. #12
    Registered User
    Join Date
    Apr 2011
    Location
    Dallas, TX
    Posts
    237
    Quote Originally Posted by Niclo Iste View Post
    So the search part needs to do a wildcard search in the results such as oem15.inf the orange text being the wild card. I would assume oem*.inf would work but I still need to know how to get it to pick that out of the search results one associated with a specific vendor such as samsung or intel. If you try the command out in cmd you'll see what I'm looking at.

    IF {Statement} {If statement is TRUE, perform this action}

    You could maybe get it to remove ALL oem*.inf files.... or you'd probably have to list out the possibilities.

    IF oem15.inf is found
    IF oem16.inf is found etc

  13. #13
    Registered User Niclo Iste's Avatar
    Join Date
    Oct 2007
    Location
    Pgh, PA
    Posts
    2,051
    Quote Originally Posted by Steve R Jones View Post
    IF {Statement} {If statement is TRUE, perform this action}

    You could maybe get it to remove ALL oem*.inf files.... or you'd probably have to list out the possibilities.

    IF oem15.inf is found
    IF oem16.inf is found etc
    Thanks Steve, but I need to leave the other oem inf files alone or it will affect the other installs. Perhaps an IF statement regarding the oem inf files that can also ID the vendor. I just am not sure of how to get it to ID the vendor of the inf.
    One Script to rule them all.
    One Script to find them.
    One Script to bring them all,
    and clean up after itself.

  14. #14
    Super Moderator
    Join Date
    Jul 2012
    Location
    Severn, Maryland, USA
    Posts
    376
    Quote Originally Posted by Niclo Iste View Post

    ... you are of the stance of "nothing can be done give up all hope".
    ??? I was just stating a fact.

    You wanted a "batch file" to "click Start". It can't.

    I'm sure there are probably some untold number of other ways to solve the problem . . . just not with a batch file. And that's all I meant. No more, no less.
    --
    Doc
    ___________Microsoft Safety & Security Center___________
    \____________________ ____.-.____ ____________________/
    \_____________\ -._)!(_.- /_____________/
    \_______\. ~\ /~ ./_______/
    \_______/

    "Men never do evil so completely and cheerfully as when they do it from religious conviction" -Blaise Pascal

  15. #15
    Registered User CeeBee's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    2,493
    Word of caution: it looks for and deletes all matches of the argument of the batch file in provider's name
    So if you run PNP.BAT i it will remove pretty much all drivers including Microsoft, Dell Inc., Intel, Samsung Electronic, Co. Ltd...
    Make sure there is a unique match...


    PNP.BAT batch file:
    Code:
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION
    SET LAST_NAME = ""
    SET LAST_PROVIDER = ""
    SET PROVIDER_TO_DELETE=%1 %2 %3
    
    IF /I "%1"=="" (
        ECHO OOOPSIE... FORGOT TO SPECIFY A NAME???
        GOTO END
        )
    
    FOR /F "tokens=1* delims=:" %%i IN ('pnputil.exe -e') DO (
        IF /I "%%i"=="Published name " (
            SET LAST_NAME="%%j"
            )
        
        IF /I "%%i"=="Driver package provider " (
            SET LAST_PROVIDER="%%j"
            REM ECHO FIND:%PROVIDER_TO_DELETE% in !LAST_PROVIDER! FOR !LAST_NAME!
            SET REPLACED_PROVIDER=!LAST_PROVIDER:%PROVIDER_TO_DELETE%=!
            SET NAME_TO_DELETE=!LAST_NAME: =!
            
            IF /I NOT !REPLACED_PROVIDER!==!LAST_PROVIDER! (
                SET NAME_TO_DELETE=!LAST_NAME: =!
                ECHO DELETING DRIVER !NAME_TO_DELETE! PROVIDER=!LAST_PROVIDER!
                REM ######REMOVE THE REM BELOW TO ACTUALLY DELETE##############
                REM PNPUTIL.EXE -f -d !NAME_TO_DELETE!
                
            ) ELSE (
                ECHO SKIPPING DRIVER !NAME_TO_DELETE! PROVIDER=!LAST_PROVIDER!
            )
        )
    )
    :END

    Code:
    C:\TEMP>pnp
    OOOPSIE... FORGOT TO SPECIFY A NAME???
    
    C:\TEMP>pnp samsung electronics
    SKIPPING DRIVER "oem0.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem1.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem2.inf" PROVIDER="   Intel"
    SKIPPING DRIVER "oem3.inf" PROVIDER="   ATI Technologies Inc."
    SKIPPING DRIVER "oem4.inf" PROVIDER="   Intel"
    SKIPPING DRIVER "oem5.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem6.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem7.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem8.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem9.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem10.inf" PROVIDER="   Microsoft"
    SKIPPING DRIVER "oem11.inf" PROVIDER="   Dell Inc."
    DELETING DRIVER "oem20.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd. "
    SKIPPING DRIVER "oem12.inf" PROVIDER="   MagicISO, Inc."
    DELETING DRIVER "oem21.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd. "
    SKIPPING DRIVER "oem30.inf" PROVIDER="   Samsung Electronic, Co. Ltd. "
    SKIPPING DRIVER "oem13.inf" PROVIDER="   Microsoft"
    DELETING DRIVER "oem22.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd. "
    SKIPPING DRIVER "oem31.inf" PROVIDER="   Samsung Electronic, Co. Ltd. "
    DELETING DRIVER "oem40.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem14.inf" PROVIDER="   Microsoft"
    DELETING DRIVER "oem23.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem32.inf" PROVIDER="   Samsung Electronic, Co. Ltd. "
    DELETING DRIVER "oem41.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem50.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem15.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem24.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem33.inf" PROVIDER="   Samsung Electronics Co., LTD"
    DELETING DRIVER "oem42.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem51.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem60.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem16.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem25.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem34.inf" PROVIDER="   Samsung Electronics Co., LTD"
    DELETING DRIVER "oem43.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem52.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem61.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem70.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem17.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem26.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem35.inf" PROVIDER="   Samsung Electronics Co., LTD"
    SKIPPING DRIVER "oem44.inf" PROVIDER="   MobileTop"
    DELETING DRIVER "oem53.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd."
    DELETING DRIVER "oem62.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem71.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem18.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd. "
    DELETING DRIVER "oem27.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem36.inf" PROVIDER="   Samsung Electronics Co., LTD"
    SKIPPING DRIVER "oem45.inf" PROVIDER="   Schunid"
    SKIPPING DRIVER "oem54.inf" PROVIDER="   SAMSUNG Inc"
    SKIPPING DRIVER "oem63.inf" PROVIDER="   Samsung Electronics"
    DELETING DRIVER "oem72.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd."
    DELETING DRIVER "oem19.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd. "
    DELETING DRIVER "oem28.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem37.inf" PROVIDER="   Samsung Electronics Co., LTD"
    DELETING DRIVER "oem46.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem55.inf" PROVIDER="   SAMSUNG Inc"
    SKIPPING DRIVER "oem64.inf" PROVIDER="   Intel Mobile Communications"
    DELETING DRIVER "oem73.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd."
    SKIPPING DRIVER "oem29.inf" PROVIDER="   Samsung Electronic, Co. Ltd. "
    DELETING DRIVER "oem38.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem47.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem56.inf" PROVIDER="   SAMSUNG Inc"
    DELETING DRIVER "oem65.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem74.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem39.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem48.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem57.inf" PROVIDER="   SAMSUNG Electronics Co.,Ltd."
    DELETING DRIVER "oem66.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem75.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd."
    DELETING DRIVER "oem49.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem58.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem67.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem76.inf" PROVIDER="   libusb.org"
    DELETING DRIVER "oem59.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    DELETING DRIVER "oem68.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem77.inf" PROVIDER="   libusb-win32"
    DELETING DRIVER "oem69.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    SKIPPING DRIVER "oem78.inf" PROVIDER="   libusb.org"
    DELETING DRIVER "oem79.inf" PROVIDER="   SAMSUNG Electronics Co., Ltd. "
    C:\TEMP>
    Protected by Glock. Don't mess with me!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •