Pnputil in batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rich205
Posts: 1
Joined: 23 Oct 2017 16:30

Pnputil in batch file

#1 Post by rich205 » 23 Oct 2017 16:48

Hi everyone,

I have been lurking here for a while, reading your scripts and trying to see If I can work out why mine doesn't work but I cant seem to make it work correctly.

The command I would like to be able to run from a batch file is this:

for /f %i in ('dir /b /s *.inf') do pnputil.exe -i -a %i

It works perfectly if I open a CMD window and paste the command into the root folder. I cant seem to make it run as a batch file though.

Any help would be wonderful.

Thank you
Rich

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Pnputil in batch file

#2 Post by aGerman » 23 Oct 2017 16:54

While FOR variables in a command line have only one percent sign they have two in a batch script. So all you have to do is replacing any occurrence of %i with %%i and you're done :wink:

Steffen

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Pnputil in batch file

#3 Post by Squashman » 23 Oct 2017 17:08

I know everyone hates it when people say RTM. But in this case, this usage is clearly defined in the help file.
To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %i is different
from %I.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Pnputil in batch file

#4 Post by Aacini » 23 Oct 2017 19:58

Just as off-topic comment: this problem have no relation to Pnputil program, but to FOR command, so the topic title is entirely confusing...

Antonio

Post Reply