Link to home
Start Free TrialLog in
Avatar of Jee Soon
Jee SoonFlag for Philippines

asked on

What's the difference between the use of %s and %%s in BAT or CMD or commandline scripts (and as seen on tech solutions on the Net)?

Hello, Everyone, I found two very similar one-liners as part of the solution to WMI issues in SCCM client installation:

1.) from https://www.virtuallyboring.com/microsoft-wmi-invalid-class-error-0x80041010/
dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %s in (moflist.txt) do mofcomp %s

2.) from https://blogs.technet.microsoft.com/yongrhee/2016/06/23/wmi-stop-hurting-yourself-by-using-for-f-s-in-dir-s-b-mof-mfl-do-mofcomp-s/
dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %%s in (moflist.txt) do mofcomp %%s

What's the difference between the two? I used the line from link #2 (%%s), but I got the error "%%s was unexpected at this time."   I understand from other posts that using "%%s" in batch files will not yield errors.  When I used the line from link #1 (%s), the command ran.

If both lines get executed successfully, whether via CMD or BAT files, would they have the same end result?

Thank you very much.
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jee Soon

ASKER

Thank you so much, Lee!!!
Exactly the answer that I needed.

Thanks a lot too for the easy-to-understand, ready-to-run examples.

Looking forward to future interactions! :)
Thank you, Lee!