Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

25 Jul 2014   #1
eawedat

Windows 7
 
 
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 System SpecsSystem Spec
.
27 Jul 2014   #2
Alejandro85

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
Reply

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




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
reading file in windows batch
i have a file b.txt with entries like : explorer.exe pid: 3136 type: File A24: D:\ftproot\logs\tagswap notepad.exe pid: 7732 type: File 18: D:\ftproot\logs\tagswap I want to read each record and extract pid and kill it. The following is only giving...
General Discussion
Batch file only works in certain directory
I made a batch file that says this: @echo off cd C:\Users\John\Desktop rename ring.gif ring.jpeg The actual batch file is saved on my I:\ drive, not my C:\ drive. My I:\ drive is an internal HDD that is able to talk with my C:\ drive. When I execute the .bat file, it does nothing...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
question - batch file only works with "unofficial" directory name
Hello... I'm using a command line batch file to backup files from my W7 Pro x64 machine to an external USB HD. Basically, "xcopy c:\......\my documents\*.*" "external HD". I couldn't get this to work until I truncated the source directory to "documents" instead of "my documents" . While the batch...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Is it possible to create a windows batch file to do this?
I generally run windows aero theme across all four monitors which i am happy with. However when i run a music app called cubase 5, i hear all sorts of squeaks and glitches when i simply move my cursor around the screen. The problem resolves itself when i switch to the standard windows classic...
General Discussion


Our Sites

Site Links

About Us

Find 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 21:59.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App