batch file doesn't work in windows 7 but worked fine in XP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

batch file doesn't work in windows 7 but worked fine in XP

#1 Post by taylormade » 14 Nov 2011 19:38

This batch worked just fine under XP but under W-7 it won't.
It says there is no command day.com, month.com etc
Any thoughts?
------------------------------------------------
@echo off & setLocal EnableDelayedExpansion

call :sub1


copy %MMM%%dat%.txt joke.txt

copy part1.txt index.htm
type joke.txt >> index.htm
type part2.txt >> index.htm


> insert.ftp echo open ftp.xxxxxxxx.com
>> insert.ftp echo username
>> insert.ftp echo password
>> insert.ftp echo bin
>> insert.ftp echo cd public_html
>> insert.ftp echo cd jotd
>> insert.ftp echo put index.htm
>> insert.ftp echo bye
ftp -s:insert.ftp



goto :eof

:sub1

@echo off > d.d

>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N DAY.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N MONTH.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N YEAR.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N DAT.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Q

debug < d.d > nul
del d.d

dat
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set dat=0%%a
for %%a in ( 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) do if errorlevel %%a set dat=%%a
echo Date %dat%

day
if errorlevel 0 set day=Sunday
if errorlevel 1 set day=Monday
if errorlevel 2 set day=Tuesday
if errorlevel 3 set day=Wednesday
if errorlevel 4 set day=Thursday
if errorlevel 5 set day=Friday
if errorlevel 6 set day=Saturday
echo Day %day%

month
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set month=0%%a
for %%a in ( 10 11 12) do if errorlevel %%a set month=%%a

if %month%==01 set MMM=Jan
if %month%==02 set MMM=Feb
if %month%==03 set MMM=Mar
if %month%==04 set MMM=Apr
if %month%==05 set MMM=May
if %month%==06 set MMM=Jun
if %month%==07 set MMM=Jul
if %month%==08 set MMM=Aug
if %month%==09 set MMM=Sep
if %month%==10 set MMM=Oct
if %month%==11 set MMM=Nov
if %month%==12 set MMM=Dec

echo MMM %MMM%
echo Month %month%

year
if errorlevel 215 set Year=2007
if errorlevel 216 set Year=2008
if errorlevel 217 set Year=2009
if errorlevel 218 set Year=2010
echo Year %Year%

del day.com
del month.com
del year.com
del dat.com

goto :eof

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#2 Post by Ed Dyreen » 15 Nov 2011 04:20

'
The old and outdated 7 is not capable of running 16debug,
hence the name 7, meaning only half of what we're used to.
It is simply too old to run those mighty XP goodies,
maybe you should consider upgrading your OS.
Last edited by Ed Dyreen on 15 Nov 2011 04:36, edited 1 time in total.

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#3 Post by taylormade » 15 Nov 2011 04:35

I applaud your sarcasm and even agree with you, but I have no choice.
My new PC hardware won't run XP. I've tried.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#4 Post by Ed Dyreen » 15 Nov 2011 04:39

'
Hmm i see, 64 bit is it ?, however I doubt there are pc that can't run 32bit, I might be wrong, but I doubt it.

My pc can run 64, 32 and 16bit versions of windows, so I am confused now... thanks :|

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#5 Post by taylormade » 15 Nov 2011 04:52

I'm not a DOS programmer but I'm thinking that DOS is pretty universal right?
I have files in a directory labeld:
Dec01.txt
Dec02.txt
Dec03.txt
etc.

I need this batch program to be able to grab the appropriate file (based on today's date) and FTP it to a remote PC.

That's what this code is supposed to be doing.
In "7" though, the date construction seems to get screwed up.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#6 Post by Ed Dyreen » 15 Nov 2011 04:57

'
The code was written to use debug to write out a *.com file,
both debug and the .com files are 16bit programs, it will never work on 64 bit like that.
There is no choice but removing the incompatibilities, sorry. :(

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#7 Post by taylormade » 15 Nov 2011 05:13

would you be willing to rewrite the code so it works?
How much if so ?
bob

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#8 Post by Ed Dyreen » 15 Nov 2011 05:31

'
I am no longer used to writing batch without library loaded, but I'll give it a try,
The batch was likely written for a pre XP dos version.
I say that because the whole DATE thingy can probably be replaced by examing the %date%
with for...

This is a quick and dirty simplification of the @Date ( dutch ) command from eDOS:

( because the date is represented differently in different languages you may need to replace )

Code: Select all

for /f "tokens=1-4 delims=:," %%a in
with

Code: Select all

for /f "tokens=1-4 delims=:." %%a in
unsure to get it working.

Code: Select all

setlocal enableExtensions enableDelayedExpansion

for /f "tokens=1-4 delims=/ " %%a in (

   "!date!"

) do (
   set "$day.name=%%~a"
   set      "$day=%%~b"
   set    "$month=%%~c"
   set     "$year=%%~d"

)
set "$?=!$month!"
if /i ["!$?:~0,1!"] == ["0"] (
   set "$?=!$?:~1!"
)
for %%? in (

   !$month!

) do    if /i ["!$?!"] == ["!$%%~?!"] (
   set "$month.name=%%~?"
)

for /f "tokens=1-4 delims=:," %%a in (

   "!time: =0!"

) do (

   set "$hour=%%~a"
   set "$min=%%~b"
   set "$sec=%%~c"
   set "$msec=%%~d"

)

for %%? in (

   year, month, month.name, day, day.name hour, min, sec, msec

) do (
   echo.  $%%~?: '!$%%~?!'
   set "$ret=!$ret!, $%%~?"
)
Last edited by Ed Dyreen on 15 Nov 2011 05:35, edited 2 times in total.

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#9 Post by taylormade » 15 Nov 2011 05:33

keep in mind that I'm not a DOS programmer.
What ever you are willing to do for me will have to be pretty much "ready to try".
bob

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#10 Post by taylormade » 15 Nov 2011 05:38

I'm looking into a solution that would allow me to run XP MODE on my Windows 7 machine.
I wonder if that would allow the batch to run

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#11 Post by Ed Dyreen » 15 Nov 2011 05:39

'
ok then examine this code then:

Code: Select all

@echo off

echo.%date%
pause

for /f "tokens=1-4 delims=/ " %%a in ( "%date%" ) do echo.a=%%~a_, b=%%~b, c=%%~c, d=%%~d_
pause

for /? |more

exit
fixed
Last edited by Ed Dyreen on 15 Nov 2011 09:30, edited 2 times in total.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: batch file doesn't work in windows 7 but worked fine in

#12 Post by Ed Dyreen » 15 Nov 2011 07:10

'
taylormade wrote:I'm looking into a solution that would allow me to run XP MODE on my Windows 7 machine.
I wonder if that would allow the batch to run
Lets face it, people that "program" without using virtualization software are playing a very dangerous game.

virtualization software or otherwise referred to as Virtual Machines is a program that acts like a pc.
You can configure it and install an OS like XP in them, The OS will 'think' it runs on a real machine.
This allows us to run old software on old OSes on a simulated old machine, that stops existing when the program is exited.

VirtualPC is a free and terrible VM from microsoft ( I tried it: fullscreen, 2D, 3D performance sucks ! )
VMWare is a paid and excellent VM ( I use it right now :)

Image

It allows you to play those great old games again like, Tiberian Sun, DOOM, resident evil, DEBUG and DATE.COM.. :D
Last edited by Ed Dyreen on 15 Nov 2011 07:35, edited 7 times in total.

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#13 Post by taylormade » 15 Nov 2011 07:14

thank you Ed.
I'm going to play around with this.
I'm also (as I said) looking into the VM solution which might prove adequate.
Again.. THANKS !!!
bob

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#14 Post by taylormade » 15 Nov 2011 09:17

Ed:
Getting there..
your code DOES retrieve the date, but my code is looking for it to be:
Nov04 I think.
(you can read the code better than me)
Can you retrofit your code (with the proper format) into my code and let me try it?
I appreciate your time here.
You might be close to a solution for me.
(the VM solution isn't practical as it would have to be running 24/7)
bob

taylormade
Posts: 18
Joined: 14 Nov 2011 19:14

Re: batch file doesn't work in windows 7 but worked fine in

#15 Post by taylormade » 15 Nov 2011 09:18

If you run the Date part of my original code in a XP box, you can see how the date is obtained then used in the operation.
bob

Post Reply