Solved

"Invalid number of parameters" error in xcopy batch file

Posted on 2009-05-14
8
1,713 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
Comment Utility
Silly first question maybe but why the "mcopy" after each xcopy?
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Monkey_Bazooka
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 43

Accepted Solution

by:
Steve Knight earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now