1

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
1

3 Answers 3

1

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"...

2
  • 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. Jun 18, 2013 at 8:00
  • @StrangerfromFarCoastr Did you try to dir \\gronk\shared\ZInstaller\latest*.*? Jun 18, 2013 at 9:38
0

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.

12
  • I got invalid parameter #1 : \\gronk\shared\ZInstaller\latest*.* with and without quotes. Jun 18, 2013 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, 2013 at 17:08
  • Yes i did. How should it be if it's not that? Jun 19, 2013 at 2:34
  • I mentioned the usage above: source dir, then destination dir and finally file list.
    – Karan
    Jun 19, 2013 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. Jun 21, 2013 at 2:54
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .