bbimis
asked on
keep getting an error the syntax of the command is wrong
i have the following code where i'm trying to look for files and move them to a shared server. i keep getting an error about incorrect syntax. i'm trying to execute the bat file through psexec
here is what i have
thanks!
here is what i have
@echo off
REM COPY Database Files from Manager System to Training Computer and generate log
set /p UserInput="enter server computer ip address: "
for /R %G IN (*.mdb) DO xcopy "%G" '\\%UserInput%\backup' echo %G >> c:\filelog.txt
echo Database Files copied
REM COPY PAYROLL DB
xcopy c:\payroll\some.mdb '\\%UserInput%\backup'
echo payroll database file copied
REM COPY ini files
xcopy c:\windows\some.ini '\\%UserInput%\backup'
xcopy c:\windows\another.ini '\\%UserInput%\backup'
echo ini files copied
REM Copy the My Documents Directory to the training computer
xcopy 'C:\Documents and Settings\Manager\My Documents' '\\%UserInput%\backup'
echo mydocuments files copied
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no it says the syntax of the command is incorrect.
with the cmd /k command i get the filename, directory name, or volume label syntax is incorrect.
i'm sure the issue is with my variable use
with the cmd /k command i get the filename, directory name, or volume label syntax is incorrect.
i'm sure the issue is with my variable use
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Using single quotes will work in most cases, but the official way is to use double quotes.
ASKER
when i do enter the computername or ip address i get the following error
Does '\\server\c\backup' specify a file name or directory name on the target (F=File, D=Directory)
thanks!
Does '\\server\c\backup' specify a file name or directory name on the target (F=File, D=Directory)
thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you also copying sub-folders from source "%%G"? If so, add the /e or /s switch.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes. per Qlemo's post re: using the backslash. It works for single or multiple files. The /i switch just works for multiple files. Just use the backslash.
Also, since you're traversing folders, and each file is copied to the same folder, you aren't covering for potential duplicate filenames. If one is found, xcopy will prompt you to Overwrite (Yes/No/All)?
Also, since you're traversing folders, and each file is copied to the same folder, you aren't covering for potential duplicate filenames. If one is found, xcopy will prompt you to Overwrite (Yes/No/All)?
One more thing. the "echo" lines, after the first one, are not pointing to the log file so they would just display on screen. Lines 10, 15 and 19.
ASKER
Thanks I will look at it Monday and reward points have a good weekend
ASKER
pony10us: as for the starting folder being the root dir. wouldn't it be for c:\ /R ...... ?
As you can tell i'm still learning this. Thanks!
As you can tell i'm still learning this. Thanks!
ASKER
thanks! all!
Thank you for the points
If you are looking for *.mdb anywhere on the C: drive then you could do "c:\ /R" however that would negate the need for the PAYROLL section since it is looking for a *.mdb as well and it would have already been found and acted upon.
Also, you may find that it will take longer to search the entire drive and may (probably will) find a lot of *.mdb files you don't want.
as for the starting folder being the root dir. wouldn't it be for c:\ /R ...... ?
If you are looking for *.mdb anywhere on the C: drive then you could do "c:\ /R" however that would negate the need for the PAYROLL section since it is looking for a *.mdb as well and it would have already been found and acted upon.
Also, you may find that it will take longer to search the entire drive and may (probably will) find a lot of *.mdb files you don't want.
thanks for the update, bbmis! Have a nice day.
What does your psexec line look like?
For debugging purposes, just run...
Open in new window
Add the -u switch if needed.
This opens a cmd prompt as the user.
Then, run your bat file and see what errors show.