MOVE command does not work from .BAT or .CMD script

Archived from groups: microsoft.public.windowsxp.general (More info?)

I have a .BAT file which moves backup files from the local hard drive to a
network share. It worked fine under Win98SE, but fails under WinXP. The
command which fails is:

MOVE /Y Backup\*.* \\ServerName\ShareName\FolderName

It returns a message "Bad command or file name".

If I open a command window, navigate to the same folder, and issue the exact
same command, it works fine. Any idea why the MOVE command would not run in a
batch file? Any way to make this work properly?
8 answers Last reply
More about move command work script
  1. Archived from groups: microsoft.public.windowsxp.general (More info?)

    "Motek Kore Guy" <MotekKoreGuy@discussions.microsoft.com> wrote in message
    news:B6132884-20CA-4E0B-AEDD-144F3E923354@microsoft.com...
    > I have a .BAT file which moves backup files from the local hard drive to a
    > network share. It worked fine under Win98SE, but fails under WinXP. The
    > command which fails is:
    >
    > MOVE /Y Backup\*.* \\ServerName\ShareName\FolderName
    >
    > It returns a message "Bad command or file name".
    >
    > If I open a command window, navigate to the same folder, and issue the
    exact
    > same command, it works fine. Any idea why the MOVE command would not run
    in a
    > batch file? Any way to make this work properly?

    There is something strange about your post. "Bad command
    or file name" is a DOS error message - under WinXP the
    wording is different. Furthermore, "move" is an internal
    command under WinXP. If you have a Command Processor
    then you have "move". I suspect the problem is caused by
    some other command in your batch file, not by "move".
    What other commands do you have in that batch file?
  2. Archived from groups: microsoft.public.windowsxp.general (More info?)

    I agree, it's strange. The .BAT file is like this:

    @ECHO ON
    C:
    CD "\Data Files\Accounting Data"
    COPY *.* \\ServerName\ShareName\DataBackupDirectory
    MOVE Backup\*.* \\ServerName\ShareName\DataBackupDirectory\Backup

    The COPY command works fine. I get the "Bad command or file name"
    immediately after the MOVE command (which is obvious as I have echo on), and
    nothing gets moved. I can copy the command from the window and paste it into
    another command box, and it works fine. I have tried renaming the .BAT file
    to .CMD, and it does the same thing.


    "Pegasus (MVP)" wrote:

    >
    > "Motek Kore Guy" <MotekKoreGuy@discussions.microsoft.com> wrote in message
    > news:B6132884-20CA-4E0B-AEDD-144F3E923354@microsoft.com...
    > > I have a .BAT file which moves backup files from the local hard drive to a
    > > network share. It worked fine under Win98SE, but fails under WinXP. The
    > > command which fails is:
    > >
    > > MOVE /Y Backup\*.* \\ServerName\ShareName\FolderName
    > >
    > > It returns a message "Bad command or file name".
    > >
    > > If I open a command window, navigate to the same folder, and issue the
    > exact
    > > same command, it works fine. Any idea why the MOVE command would not run
    > in a
    > > batch file? Any way to make this work properly?
    >
    > There is something strange about your post. "Bad command
    > or file name" is a DOS error message - under WinXP the
    > wording is different. Furthermore, "move" is an internal
    > command under WinXP. If you have a Command Processor
    > then you have "move". I suspect the problem is caused by
    > some other command in your batch file, not by "move".
    > What other commands do you have in that batch file?
    >
    >
    >
  3. Archived from groups: microsoft.public.windowsxp.general (More info?)

    On Wed, 24 Aug 2005 20:33:47 -0700, "Motek Kore Guy"
    <MotekKoreGuy@discussions.microsoft.com> wrote:

    >I agree, it's strange. The .BAT file is like this:
    >
    >@ECHO ON
    >C:
    >CD "\Data Files\Accounting Data"
    >COPY *.* \\ServerName\ShareName\DataBackupDirectory
    >MOVE Backup\*.* \\ServerName\ShareName\DataBackupDirectory\Backup
    >
    >The COPY command works fine. I get the "Bad command or file name"
    >immediately after the MOVE command (which is obvious as I have echo on), and
    >nothing gets moved. I can copy the command from the window and paste it into
    >another command box, and it works fine.

    I'm guessing bad line terminator between the two lines, or a
    non-printing character somewhere.

    --
    Stan Brown, Oak Road Systems, Tompkins County, New York, USA
    http://OakRoadSystems.com/
    "My theory was a perfectly good one. The facts were misleading."
    -- /The Lady Vanishes/ (1938)
  4. Archived from groups: microsoft.public.windowsxp.general (More info?)

    On Thu, 25 Aug 2005 10:48:14 -0400, Stan Brown
    <the_stan_brown@fastmail.fm> wrote:

    >I'm guessing bad line terminator between the two lines, or a
    >non-printing character somewhere.

    I withdraw my comment -- I think the point Pegasus bought up is the
    key. "Bad command or file name" is not a CMD.EXE error message.

    If you are somehow running through old DOS (COMMAND.COM), you may be
    hitting a line-length limit.

    --
    Stan Brown, Oak Road Systems, Tompkins County, New York, USA
    http://OakRoadSystems.com/
    "My theory was a perfectly good one. The facts were misleading."
    -- /The Lady Vanishes/ (1938)
  5. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Thank you, Stan, this was the hint I needed. I had all of the .BAT files,
    along with shortcuts (.PIF) saved off in a folder, and restored the folder to
    the XP machine. Apparently, .PIF files created in Windows 98 will work in
    Windows XP, but invoke the COMMAND.COM processor rather than the CMD.EXE
    processor. In Win98, it worked because MOVE was an external command, not an
    internal one. I deleted the shortcut, recreated it, and now it works fine.

    Thanks again!

    --- Jeremy Segal

    "Stan Brown" wrote:

    > On Thu, 25 Aug 2005 10:48:14 -0400, Stan Brown
    > <the_stan_brown@fastmail.fm> wrote:
    >
    > >I'm guessing bad line terminator between the two lines, or a
    > >non-printing character somewhere.
    >
    > I withdraw my comment -- I think the point Pegasus bought up is the
    > key. "Bad command or file name" is not a CMD.EXE error message.
    >
    > If you are somehow running through old DOS (COMMAND.COM), you may be
    > hitting a line-length limit.
    >
    > --
    > Stan Brown, Oak Road Systems, Tompkins County, New York, USA
    > http://OakRoadSystems.com/
    > "My theory was a perfectly good one. The facts were misleading."
    > -- /The Lady Vanishes/ (1938)
    >
  6. Archived from groups: microsoft.public.windowsxp.general (More info?)

    What's even stranger is that the error message "Bad command
    or file name" does not exist under WinXP! There something
    wrong either with your environment or with your reporting.


    "Motek Kore Guy" <MotekKoreGuy@discussions.microsoft.com> wrote in message
    news:0CD1F9AE-366D-4E1F-A5E6-CBD547B06354@microsoft.com...
    > I agree, it's strange. The .BAT file is like this:
    >
    > @ECHO ON
    > C:
    > CD "\Data Files\Accounting Data"
    > COPY *.* \\ServerName\ShareName\DataBackupDirectory
    > MOVE Backup\*.* \\ServerName\ShareName\DataBackupDirectory\Backup
    >
    > The COPY command works fine. I get the "Bad command or file name"
    > immediately after the MOVE command (which is obvious as I have echo on),
    and
    > nothing gets moved. I can copy the command from the window and paste it
    into
    > another command box, and it works fine. I have tried renaming the .BAT
    file
    > to .CMD, and it does the same thing.
    >
    >
    > "Pegasus (MVP)" wrote:
    >
    > >
    > > "Motek Kore Guy" <MotekKoreGuy@discussions.microsoft.com> wrote in
    message
    > > news:B6132884-20CA-4E0B-AEDD-144F3E923354@microsoft.com...
    > > > I have a .BAT file which moves backup files from the local hard drive
    to a
    > > > network share. It worked fine under Win98SE, but fails under WinXP.
    The
    > > > command which fails is:
    > > >
    > > > MOVE /Y Backup\*.* \\ServerName\ShareName\FolderName
    > > >
    > > > It returns a message "Bad command or file name".
    > > >
    > > > If I open a command window, navigate to the same folder, and issue the
    > > exact
    > > > same command, it works fine. Any idea why the MOVE command would not
    run
    > > in a
    > > > batch file? Any way to make this work properly?
    > >
    > > There is something strange about your post. "Bad command
    > > or file name" is a DOS error message - under WinXP the
    > > wording is different. Furthermore, "move" is an internal
    > > command under WinXP. If you have a Command Processor
    > > then you have "move". I suspect the problem is caused by
    > > some other command in your batch file, not by "move".
    > > What other commands do you have in that batch file?
    > >
    > >
    > >
  7. Archived from groups: microsoft.public.windowsxp.general (More info?)

    On Thu, 25 Aug 2005 10:19:02 -0700, "Motek Kore Guy"
    <MotekKoreGuy@discussions.microsoft.com> wrote:

    >"Stan Brown" wrote:
    >> I withdraw my comment -- I think the point Pegasus bought up is the
    >> key. "Bad command or file name" is not a CMD.EXE error message.
    >>
    >> If you are somehow running through old DOS (COMMAND.COM), you may be
    >> hitting a line-length limit.
    >>
    >Thank you, Stan, this was the hint I needed. I had all of the .BAT files,
    >along with shortcuts (.PIF) saved off in a folder, and restored the folder to
    >the XP machine. Apparently, .PIF files created in Windows 98 will work in
    >Windows XP, but invoke the COMMAND.COM processor rather than the CMD.EXE
    >processor. In Win98, it worked because MOVE was an external command, not an
    >internal one. I deleted the shortcut, recreated it, and now it works fine.

    I'm delighted you found the problem, but I think Pegasus deserves
    the lion's share of the credit. He's the one who pointed out the
    error message couldn't possibly be right -- I didn't pick up on the
    COMMAND.COM issue at all till I saw his note.

    Anyway, thanks for letting us all know. It's so satisfying when a
    nasty mystery turns out to have a simple explanation!

    --
    Stan Brown, Oak Road Systems, Tompkins County, New York, USA
    http://OakRoadSystems.com/
    "What in heaven's name brought you to Casablanca?"
    "My health. I came to Casablanca for the waters."
    "The waters? What waters? We're in the desert."
  8. Archived from groups: microsoft.public.windowsxp.general (More info?)

    "Stan Brown" <the_stan_brown@fastmail.fm> wrote in message
    news:ijbug15hacba8mhbervvj1fa32kcho4jbr@4ax.com...
    > On Thu, 25 Aug 2005 10:19:02 -0700, "Motek Kore Guy"
    > <MotekKoreGuy@discussions.microsoft.com> wrote:
    >
    > >"Stan Brown" wrote:
    > >> I withdraw my comment -- I think the point Pegasus bought up is the
    > >> key. "Bad command or file name" is not a CMD.EXE error message.
    > >>
    > >> If you are somehow running through old DOS (COMMAND.COM), you may be
    > >> hitting a line-length limit.
    > >>
    > >Thank you, Stan, this was the hint I needed. I had all of the .BAT files,
    > >along with shortcuts (.PIF) saved off in a folder, and restored the
    folder to
    > >the XP machine. Apparently, .PIF files created in Windows 98 will work in
    > >Windows XP, but invoke the COMMAND.COM processor rather than the CMD.EXE
    > >processor. In Win98, it worked because MOVE was an external command, not
    an
    > >internal one. I deleted the shortcut, recreated it, and now it works
    fine.
    >
    > I'm delighted you found the problem, but I think Pegasus deserves
    > the lion's share of the credit. He's the one who pointed out the
    > error message couldn't possibly be right -- I didn't pick up on the
    > COMMAND.COM issue at all till I saw his note.

    Maybe, but it was your post that finally nailed the culprit.
Ask a new question

Read More

Microsoft Backup Command Prompt Hard Drives Windows XP