• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2206
  • Last Modified:

"Invalid number of parameters" error in xcopy batch file

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
Monkey_Bazooka
Asked:
Monkey_Bazooka
  • 5
  • 2
1 Solution
 
Steve KnightIT ConsultancyCommented:
Silly first question maybe but why the "mcopy" after each xcopy?
0
 
Steve KnightIT ConsultancyCommented:
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
 
Steve KnightIT ConsultancyCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Monkey_BazookaAuthor Commented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
AmazingTechCommented:
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
 
Monkey_BazookaAuthor Commented:
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

Technology Partners: 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!

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now