Solved

"Invalid number of parameters" error in xcopy batch file

Posted on 2009-05-14
8
1,767 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
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 125 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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…

785 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