Batch File: works under cmd-Windows , NOT under MS-DOS


  1. Posts : 1
    Windows 7
       #1

    Batch File: works under cmd-Windows , NOT under MS-DOS


    I made these codes to backup files :


    Code:
    set p=C:\Users\
    
    for /f %%a in ('dir C:\Users\ /b') do (
    
    if not "%%a"=="Public", (
    set fileDest=C:\Backup-%%a_%date:~7,2%.%date:~4,2%.%date:~10,4%
    If Not Exist "%fileDest%" mkdir "%fileDest%"
    set "fullPath=%p%%%a%"
    xcopy "%fullPath%" %fileDest% /e /h /y /k
    rem call blah.bat
    )
    )
    When I test it under cmd of Windows 7 , it works great!!

    When I try it under MS-DOS(VirtualBOX) it does not

    It gives me these errors :



    Version of MS-DOS used under VirtualBox is 6.22

    any suggestion ?
      My Computer


  2. Posts : 2,468
    Windows 7 Ultimate x64
       #2

    The command line in Windows 7 is a superset of the commands avaiable in the real DOS 6.22, not exactly the same. Over the newer versions it has added new commands and syntax, and it seems that you're using something new in the FOR command, not available back then.

    I'm don't know what it support exactly, but, in DOS, open HELP FOR and check what syntax does it support. You'll have to create another version of the .bat file for DOS which uses only the features there, or restrict to the subset of commands common to both DOS 6.22 and Win7.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:57.
Find Us