Monkey_Bazooka
asked on
"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?
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
Silly first question maybe but why the "mcopy" after each xcopy?
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?
i.e. xcopy /D /S /E /I /H /O /Q "\\%var1%\c$\documents and settings\%var2%\desktop" "\\%var1%\c$\documents and settings\%var3%\desktop"
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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
ASKER
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