Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to make a bat file that transfers two or three files from my server to my PC. I kept getting invalid number of parameters. I;m running Windows 7 btw.

So far this is what i came up with

@echo OFF
@echo Updating EXE

xcopy \\gronk\shared\ZInstaller\latest\*.* %ProgramFiles%\ZInstaller /D /U /Y
@echo.

@echo Update Complete!
@echo.
pause
share|improve this question
    
Any idea what went wrong? –  Stranger from a Far Coast Jun 18 '13 at 7:51
add comment

3 Answers 3

on my computer, the programfiles var contains a space:

C:\Document and Settings>echo %programfiles%
C:\Program Files

i think xcopy interprets this as 2 parameters, therefore you have one too more parameter. Try escaping %ProgramFiles%\ZInstaller with double quotes: "%ProgramFiles%\ZInstaller"...

share|improve this answer
    
Thanks, but now i get Invalid drive specification 0file(s) copied. Most probably have to do with these lines \\gronk\shared\ZInstaller\latest*.* I'm trying to not use the mapped network drive involved as i'm creating this bat on multiple computers with different mapped drive. And the server i have, has a user password account in order to log in. –  Stranger from a Far Coast Jun 18 '13 at 8:00
    
@StrangerfromFarCoastr Did you try to dir \\gronk\shared\ZInstaller\latest*.*? –  Werner Henze Jun 18 '13 at 9:38
add comment

Quote all paths that might contain spaces, and use robocopy instead to deal with UNC paths better.

The equivalent of /D and /U should be /XO and /XL respectively.

share|improve this answer
    
I got invalid parameter #1 : \\gronk\shared\ZInstaller\latest*.* with and without quotes. –  Stranger from a Far Coast Jun 18 '13 at 9:02
    
As robocopy /? says, the usage is robocopy source destination [file [file]...] [options], where source/dest are directory names and the file list (in your case latest*.*) is specified separately at the end. Did you simply use robocopy "\\gronk\shared\ZInstaller\latest\*.*" "%ProgramFiles%\ZInstaller"? –  Karan Jun 18 '13 at 17:08
    
Yes i did. How should it be if it's not that? –  Stranger from a Far Coast Jun 19 '13 at 2:34
    
I mentioned the usage above: source dir, then destination dir and finally file list. –  Karan Jun 19 '13 at 14:23
    
robocopy "\\standardmssql\sishared\Biims_SISB\latest" "%ProgramFiles%\BIIMS" /XO /XL I tried out your method, after running into numnerous errors. This one works HOWEVER, a new error pops up Logon failure: unknown user name or bad password. Is there any other lines i should add? Also i have to run the batch as admin which is a fuss. –  Stranger from a Far Coast Jun 21 '13 at 2:54
show 7 more comments

Based on the other comments/answers it's obvious that the command should contain quotes:

xcopy \\gronk\shared\ZInstaller\latest\*.* "%ProgramFiles%\ZInstaller" /D /U /Y

With the additional errors you are getting, try to issue a

dir \\gronk\shared\ZInstaller\latest*.*

and

dir "%ProgramFiles%\ZInstaller"

To see which of the two parameters are causing the invalid drive error

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.