?
Solved

"Invalid number of parameters" error in xcopy batch file

Posted on 2009-05-14
8
Medium Priority
?
2,102 Views
Last Modified: 2012-08-14
I am trying to run the below batch and keep getting an "Invalid number of parameters" error. I have no idea where I have gone wrong. It all looks perfectly fine to me? I put pause after the first xcopy to see why nothing was copying and got the error. I want it to use after renaming a users profile to save copying their stuff across to their new profile.

Any takers?
@echo off
 
title FOLDER COPY
COLOR 1e
 
:start
cls
echo  Make sure the user has logged on and outlook has been opened successfully. 
echo  This creates folders needed for the copy to succeed.                                            
                                                                                                                                                                                                          
set /p var1=                                   Enter PC name: 
set /p var2= Enter ADM with old extension (eg: adm1234.old2): 
set /p var3=                                   Enter new ADM: 
 
xcopy mcopy  /a /T /S /E /I /H /O /Q "\\%var1%\c$\documents and settings\%var2%\desktop" "\\%var1%\c$\documents and settings\%var3%\desktop"
 
xcopy mcopy /a /t /s /e /i /h /o /q "\\%var1%\c$\documents and settings\%var2%\Application Data\Microsoft\Signatures" "\\%var1%\c$\documents and settings\%var3%\Application Data\Microsoft\Signatures"
 
xcopy mcopy /a /t /s /e /i /h /o /q "\\%var1%\c$\documents and settings\%var2%\Application Data\Microsoft\outlook\Default Outlook Profile.NK2" "\\%var1%\c$\documents and settings\%var3%\Application Data\Microsoft\outlook"
goto end
 
:end
 
cls
sleep 1
echo It's DONE Broski!! Now go have a Brewski...
sleep 3
goto start

Open in new window

0
Comment
Question by:Monkey_Bazooka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24383700
Silly first question maybe but why the "mcopy" after each xcopy?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24383722
Also /a will only copy changed files which may not be what you want, /T and /S are kinds of opposites (just use /S).  I'd probably use /d instead of /a to copy any newer files?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24383727
i.e. xcopy /D /S /E /I /H /O /Q "\\%var1%\c$\documents and settings\%var2%\desktop" "\\%var1%\c$\documents and settings\%var3%\desktop"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Monkey_Bazooka
ID: 24383968
Thanks dragon-it, the mcopy is so I don't get asked each time if it is a file or a folder that I am copying over. xcopy alone causes this to happen. A bit of a chat with google found that mcopy stopped this happening

This did work at one stage, but I started messing with the code so you would have to signon with an administrators account. It didn't work the way I wanted it too so I removed the code I added and then all of a sudden I got this invalid parameters issue.

I will give this a go at work tomorrow. Thanks again.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 24384080
mcopy is not an option on xcopy.  I presume you are referring to documents such as this about renaming xcopy.  If you'd renamed xcopy then you'd want to just use mcopy /Y /D..... etc.  rather than xcopy anyway.

http://www.csulb.edu/~murdock/xcopy.html

You don't need to use that. Please try it without the mcopy part and I think you will be find it will be OK.... perhaps with addition of a /Y to it

xcopy /Y /D /S /E /I /H /O /Q "\\%var1%\c$\documents and settings\%var2%\desktop" "\\%var1%\c$\documents and settings\%var3%\desktop"

If you find xcopy doesn't do sufficiently well for what you need then robocopy offers more options, or sometimes a straight copy command instead may be all that is needed if there are no subdirs to copy etc.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 24384103
Yes if you aren't an admin of the other computer, i.e. you can't access \\othercomputer\c$ from Start | run for instance then it's not going to work anyway using the admin only c$ share.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 24385647
Like dragon-it has already stated mcopy is not an option within Microsoft's xcopy.exe. If you replaced the xcopy.exe then that's a totally different story.

Try this script out.


FOR /F "skip=2 tokens=2-7 delims=," %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:csv') DO (
	SET Day=%%A
	SET Hour=%%B
	SET Minute=%%C
	SET Month=%%D
	SET Second=%%A
	SET Year=%%F
)
 
@echo off
 
title FOLDER COPY
COLOR 1e
 
:start
cls
echo  Make sure the user has logged on and outlook has been opened successfully. 
echo  This creates folders needed for the copy to succeed.                                            
                                                                                                                                                                                                          
set /p var1=                                   Enter PC name: 
ECHO.
DIR /ad /b "\\%var1%\c$\documents and settings\*.old*"
ECHO.
set /p var2= Enter ADM with old extension (eg: adm1234.old2): 
ECHO.
DIR /ad /b "\\%var1%\c$\documents and settings\*.*" | find /v /i ".old"
ECHO.
set /p var3=                                   Enter new ADM: 
 
xcopy /a /T /S /E /I /H /O /Q "\\%var1%\c$\documents and settings\%var2%\desktop\*.*" "\\%var1%\c$\documents and settings\%var3%\desktop\*.*"
 
xcopy /a /t /s /e /i /h /o /q "\\%var1%\c$\documents and settings\%var2%\Application Data\Microsoft\Signatures\*.*" "\\%var1%\c$\documents and settings\%var3%\Application Data\Microsoft\Signatures\*.*"
 
xcopy /a /t /s /e /i /h /o /q "\\%var1%\c$\documents and settings\%var2%\Application Data\Microsoft\outlook\Default Outlook Profile.NK2" "\\%var1%\c$\documents and settings\%var3%\Application Data\Microsoft\outlook\*.*"
goto end
 
:end
 
cls
sleep 1
echo It's DONE Broski!! Now go have a Brewski...
sleep 3
goto start

Open in new window

0
 

Author Closing Comment

by:Monkey_Bazooka
ID: 31581389
Thanks for this. I didn't try the more complicated script as this was sufficient for what I needed. Got around asking for directory or file issue by simply adding a '/' at the end. Recognised as a directory then
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question