What about this Forfiles command syntax is wrong?

5,309

Solution 1

I'm thinking you copy and pasted the syntax into cmd. You are probably facing the smart quote issue. Retype the script yourself instead of copy and pasting. Or copy to notepad, erase the quotes and then put the quotes back. then copy that and paste to cmd. Sounds silly but it is a known issue.

Solution 2

You've to use the Escape-Sign ^ for some other signs like this:

FORFILES /P "%WINDIR%\servicing\Packages" /M "Microsoft-Windows-InternetExplorer-*9.*.mum" /c "cmd ^/c echo ^"Uninstalling package @fname^" ^&^& start ^/w pkgmgr ^/up:@fname ^/norestart"

Than it should work. I don't try it with your line, but got the same error sometimes.

Share:
5,309

Related videos on Youtube

Zach L
Author by

Zach L

I've been troubleshooting since my first Windows 95 computer when solitaire wouldn't load up. I'm a student studying networking via Cisco at a local community college, but have interest in many areas of IT. I was raised on Windows and have minor experience in OS X & Unix.

Updated on September 18, 2022

Comments

  • Zach L
    Zach L over 1 year

    I was attempting to issue the following FORFILES command, and I recieved an error that distressed me (listed after the command).


    C:\Windows\system32>FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-*9.*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart"

    ERROR: Invalid syntax. '/c' option is not allowed more than '1' time(s). Type "FORFILES /?" for usage.


    I've gone over the command a few times, and it seems to be correct, but clearly isn't. I've verified the paths and arguments. I'm running the command-line as administrator on Windows 7 32-bit SP1. Any insight would be much appreciated.