MSFN Forum: some batch file coding help needed... - MSFN Forum

Jump to content



  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

some batch file coding help needed... with a batch code brain teaser... Rate Topic: -----

#1 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 17 October 2006 - 03:16 AM

Hey all,

There I was finally uploading my big fat present for all you intrepid Windows 98 se users (125mb in size) just today when I discovered a few more problems I hadn't noticed before. :huh: The solution involves being able to check the version of a dll file using the command line in Win98se --- i've been able to use other methods to see if a file needs replacing up till this point (some even quite ingenious if I say so myself!) but when you get a modified file that is exactly the same size as the one its replacing, and there were no registry keys created, then it seems the only way is to check the file version. But how can you do that from the command line? Does anyone know of a tool that interrogates a file for its version number?

Or is there another way to kill off my mangy & quite rabid dog of a problem?

I am just itching to upload my pressie :rolleyes: so fast help is much appreciated :yes: Thanks in advance!!!

EDIT: I've found a solution that checks 2 files to see if they are identical, not just in size but the contents as well. This should solve the problem, but i'd still be interested to know if the above can be done.
@echo off
:: this batch file compares 2 files to see if they are identical
@echo off
fc %1 %2> tmp$$$
type tmp$$$ | find /i "fc: no differences encountered" >nul
echo.
  if ERRORLEVEL 1 echo Files %1 and %2 are different
  if ERRORLEVEL 1 goto END
  if ERRORLEVEL 0 echo Files %1 and %2 are identical
 echo.
  :END
PAUSE
CLS
EXIT

This post has been edited by soporific: 02 November 2006 - 06:46 PM



#2 User is offline   oscardog 

  • Member
  • PipPip
  • Group: Members
  • Posts: 234
  • Joined: 29-June 06

Posted 17 October 2006 - 05:48 AM

The only way I know is to use filever.exe from a command prompt.
E:\FILEVER\FILEVER.EXE [/S] [/V] [/E] [/X] [/B] [/A] [/D] [[drive:][path][filena
me]]

/S Displays files in specified directory and all subdirectories.
/V List verbose version information if available.
/E List executables only.
/X Displays short names generated for non-8dot3 file names.
/B Uses bare format (no dir listing).
/A Don't display file attributes.
/D Don't display file date and time.
>c:\version.txt
before running your setup.bat
Works from command prompt but not in pure dos
----- W32i DLL ENU 4.0.0.1111 shp 819,200 08-24-1996 shell32.dll

#3 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 17 October 2006 - 06:52 AM

[quote name='oscardog' date='Oct 17 2006, 09:48 PM' post='574079']
The only way I know is to use filever.exe from a command prompt.
E:\FILEVER\FILEVER.EXE [/S] [/V] [/E] [/X] [/B] [/A] [/D] [[drive:][path][filena
me]]

After some research I gather you are talking about the utility that is on the Windows 2000 or above CD. I then went looking for variations of filever.exe and found this

It spews out heaps of info, but more importantly it DOES display the crucial piece of information ... the problem I encountered was trying to determine if LLXX's Copy2Gb fix was installed or not. The info I can now search for is "FixedBy = LittyX" which I'm now glad she put in. Thankx LLXX.

So i have the solution, thanks for the tip dude.
:thumbup

#4 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 18 October 2006 - 08:45 PM

More help needed !!

I have decided to do more checking on my (now) multiple projects I want to release ASAP, and so I have created a test Win98 installation using a dummy drive and the D drive to install the operating system. This is to check that all updates properly recognise that Windows is a) not on the C drive, and b) not in a directory called Windows. The installation directory is D:\Win98

I have 2 questions:

1) How can you force Windows to install in a directory with a name that contains a space? I wanted to see if I put quotes around all the path locations in my code and this would have been a good way to check, but I can't seem to do it. I changed the msbatch.inf ChangeDir value from ChangeDir=0 to ChangeDir=1 so I could try lots of options, but Windows setup won't allow any variations with a space in the directory name. Or maybe I was doing something wrong. SO can anyone confirm if this is an official limitation? Or am i just a dunderhead...

2) I have also discovered something weird. So, I've performed a fresh, clean install of Win98se with absolutely no updates or fixes. And the weirdness is the OS seems to want to store its Autoexec.bat file on the C drive rather than on the D drive which is what I expected. I use the autoexec.bat file to perform some Real DOS file replacements that you can't use the wininit.ini method for (ie Copy2Gb) and it took a few minutes to realise why it wasn't working because the code was looking for an autoexec.bat file on the d drive when its on the C drive ... Anyone know why this is?

Thanks in advance ...

#5 User is offline   LLXX 

  • MSFN Junkie
  • PipPipPipPipPipPipPipPipPip
  • Group: Banned
  • Posts: 3,399
  • Joined: 04-December 05

Posted 18 October 2006 - 09:59 PM

View Postsoporific, on Oct 18 2006, 09:45 PM, said:

1) How can you force Windows to install in a directory with a name that contains a space? I wanted to see if I put quotes around all the path locations in my code and this would have been a good way to check, but I can't seem to do it. I changed the msbatch.inf ChangeDir value from ChangeDir=0 to ChangeDir=1 so I could try lots of options, but Windows setup won't allow any variations with a space in the directory name. Or maybe I was doing something wrong. SO can anyone confirm if this is an official limitation? Or am i just a dunderhead...

2) I have also discovered something weird. So, I've performed a fresh, clean install of Win98se with absolutely no updates or fixes. And the weirdness is the OS seems to want to store its Autoexec.bat file on the C drive rather than on the D drive which is what I expected. I use the autoexec.bat file to perform some Real DOS file replacements that you can't use the wininit.ini method for (ie Copy2Gb) and it took a few minutes to realise why it wasn't working because the code was looking for an autoexec.bat file on the d drive when its on the C drive ... Anyone know why this is?

Thanks in advance ...
1. That's a bad idea. Windows directory needs to be accessible from DOS, and so should conform to 8.3 naming convention.
2. Is the BIOS booting the C drive or the D drive, i.e. where is the kernel (MSDOS.SYS and IO.SYS) stored? The autoexec.bat and config.sys are located on the same drive that the DOS kernel is.

#6 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 18 October 2006 - 10:34 PM

View PostLLXX, on Oct 19 2006, 01:59 PM, said:

1. That's a bad idea. Windows directory needs to be accessible from DOS, and so should conform to 8.3 naming convention.
2. Is the BIOS booting the C drive or the D drive, i.e. where is the kernel (MSDOS.SYS and IO.SYS) stored? The autoexec.bat and config.sys are located on the same drive that the DOS kernel is.


Consciously installing Windows 98se into a directory with spaces IS a bad idea, I agree, but if you re-read the context, it was only to check that my code for my Win98se "yeah yeah so where the hell are they" projects are fool-proof. Are you saying that this is an OFFICIAL limitation by Microsloth and they prohibit you from doing it? Which is my original question ... :)

With regard to the autoexec.bat, the drives layout is:

- C: drive is a Primary partition, formatted with FAT32
- D: is a logical partition, formatted with FAT32

IO.sys and MSDOS.sys are both on the C drive. I guess its got something to do with no support for multiple visible primary partitions (as Partition Magic tells me). So the OS uses the 1st primary partition for some system files. If this is always the case, then the code is fine ... autoexec.bat will always be in the C:\autoexec.bat location. Or am i missing something here ...

This post has been edited by soporific: 18 October 2006 - 10:35 PM


#7 User is offline   LLXX 

  • MSFN Junkie
  • PipPipPipPipPipPipPipPipPip
  • Group: Banned
  • Posts: 3,399
  • Joined: 04-December 05

Posted 19 October 2006 - 12:16 AM

FDISK won't let you do it, but you can create more than one primary partition and boot from any of them.

#8 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 19 October 2006 - 12:30 AM

View PostLLXX, on Oct 19 2006, 04:16 PM, said:

FDISK won't let you do it, but you can create more than one primary partition and boot from any of them.

Yes you can, but for my context (that word keeps popping up!) if you created two primary partitions, one of them will be hidden and thus the drive letters won't be right. I wanted to test an installation on the d drive, but if you have 2 primary partitons, Windows will only see one of them and won't allow a d drive install (unless that is you also have a logical partition after the primaries).

So, really, what I am asking is --- is it humanly possible to have a windows 98 installation with the autoexec.bat on any other drive than the C drive? To achieve this, Windows will have to *SEE* both primary partitions in order to avoid using the first one. And Parition Magic 8 tells me that data corruption may occur if Windows sees 2 primaries.

Again, the only reason I'm asking is to know for sure that my code won't break. I am NOT looking to perform weird installations of Windows 98se for the fun of it. It is so I don't have a red face when my code breaks. In fact, the Copy2gb_installer I just posted a few minutes ago will break if this is the case. LLXX, I would suggest you have an interest in it working perfectly B) Let me know if the installer is of any use!

#9 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 8,792
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 19 October 2006 - 10:15 AM

Soporific said:

So, really, what I am asking is --- is it humanly possible to have a windows 98 installation with the autoexec.bat on any other drive than the C drive?

Short answer: NO

Long Answer: NO, but this has nothing to do with Windows 9x, is a "feature" of DOS:
On the SAME drive that was booted MUST reside:
IO.SYS
MSDOS.SYS
Autoexec.bat
Config.sys
and, normally, COMMAND.COM (but this can be changed through a setting in Autoexec.bat):
http://goforit.unk.e...dos/msdos09.htm

The same reason why you cannot rename "Autoexec.bat" to, say, "myauto.bat", those filenaes are encoded in the DOS files, and they must be on THAT same partition.

Nothing prevents you however to make a c:\autoexec.bat like this:
CALL D:\Autoexec.bat


Moreover, though I cannot say if it useful in your "context" ;) Windows 98 can be installed "completely" to a Logical Volume inside extended partition:
http://www.allensmit...XOSL/II.htm#II1
of course you will need a boot manager to hide partitions preceding the one on which you installed Windows 98, or those ones need to be with a filesystem that Win98 won't recognize, but the drive booted will remain "C:".

Another interesting approach could be the one hinted here, though I never tested it for this particular purpose:
http://www.geocities...eedatarecovery/
http://www.v72735.f2...ssig/index.html

but again, since the Letter Assigner has to be invoked from Autoexec.bat, you will however need to have it on the initial boot "C:" drive.

jaclaz

P.S.: to check version of a .dll/.exe/.ocx, check this also:
http://lbrisar.htmlp..._cmd32.html#top

This post has been edited by jaclaz: 19 October 2006 - 10:43 AM


#10 User is offline   glaurung 

  • Newbie
  • Group: Members
  • Posts: 34
  • Joined: 18-July 06

Posted 19 October 2006 - 11:27 AM

View Postsoporific, on Oct 18 2006, 09:45 PM, said:

1) How can you force Windows to install in a directory with a name that contains a space? I wanted to see if I put quotes around all the path locations in my code and this would have been a good way to check, but I can't seem to do it. I changed the msbatch.inf ChangeDir value from ChangeDir=0 to ChangeDir=1 so I could try lots of options, but Windows setup won't allow any variations with a space in the directory name. Or maybe I was doing something wrong. SO can anyone confirm if this is an official limitation? Or am i just a dunderhead...


I don't think you can. The first phase of the windows setup wizard (where you choose the windows directory and all the files are copied) is a windows 3.1 program, which means it cannot understand or use long file names. So windows will always be installed to a short name directory.

#11 User is offline   MDGx 

  • 98SE2ME + 98MP10
  • Group: Super Moderator
  • Posts: 2,677
  • Joined: 22-November 04
  • OS:none specified
  • Country: Country Flag

Posted 19 October 2006 - 02:24 PM

You may wish to run Letter Assigner [the native DOS executable] from your config.sys [which has to be on C:\ root] with a command like this:

INSTALL=C:\LETASSIG\LETASSIG.EXE

Most executables/TSRs/devices/memory residents that are meant to run either from autoexec.bat or from native DOS prompt can be run from within config.sys using the INSTALL / INSTALLHIGH commands.
All MS-DOS 6/7/8 editions have install(high) built-in.

INSTALLHIGH is only used if upper memory is present at boot time by loading an UMA/UMB memory manager [UMBPCI.SYS, EMM386.EXE, QEMM386.SYS, RM386.EXE, 386MAX.SYS etc], and if you want to load "high" [in UMA] a device/driver/TSR/memory resident program.

MSCDEX, SMARTDRV, MOUSE*.*, DOSKEY etc can be loaded this way from config.sys, for example.

Then you can load up your autoexec.bat from the drive/partition created/reassigned by LetAssig.

This is only a suggestion, I have never used Letter Assigner.

Another solution that doesn't involve LetAssig [but is only a workaround] would be to create a "fake" autoexec.bat in C:\ root, with these 2 lines:

@echo off
call d:\bats\autoexec.bat

which in turn will run your "real" autoexec.bat from D:\BATS , or wherever else you want to place it into.
Your d:\bats\autoexec.bat can also be named to anything else, if you like, but don't change its file extension.

______________________________


glaurung:

Good point.
M$ Windows [any edition/version, including all 3.xx, 9x + NTx based OSes] cannot install in a LFN directory.
Windows install folder must abide by MS-DOS SFNs [Short File Names] convention: 8.3 characters, which cannot be certain symbols, like:

/ \ ? > < | * " :

______________________________

IMO:
Autoexec.bat and config.sys names and extensions [but not their locations] can be changed by hexing IO.SYS [which has to reside inside C:\ root] using any decent hex editor.

And I believe COMMAND.COM name [extension must be COM or EXE] can be changed this way too.

HTH

This post has been edited by MDGx: 19 October 2006 - 02:28 PM


#12 User is offline   Petr 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 981
  • Joined: 15-April 05
  • OS:98SE
  • Country: Country Flag

Posted 19 October 2006 - 04:06 PM

View Postsoporific, on Oct 19 2006, 03:45 AM, said:

1) How can you force Windows to install in a directory with a name that contains a space? I wanted to see if I put quotes around all the path locations in my code and this would have been a good way to check, but I can't seem to do it. I changed the msbatch.inf ChangeDir value from ChangeDir=0 to ChangeDir=1 so I could try lots of options, but Windows setup won't allow any variations with a space in the directory name. Or maybe I was doing something wrong. SO can anyone confirm if this is an official limitation? Or am i just a dunderhead...


As it was already explained it seems to be not possible to force Windows setup to use LFN.

Just one idea that might work - untested:

1. Create "C:\Long Windows Directory" directory before starting setup. SFN will be "LONGWI~1"

2. Ask Windows Setup to use "LONGWI~1" directory

Will it work?

Petr

#13 User is offline   MDGx 

  • 98SE2ME + 98MP10
  • Group: Super Moderator
  • Posts: 2,677
  • Joined: 22-November 04
  • OS:none specified
  • Country: Country Flag

Posted 19 October 2006 - 04:48 PM

Petr, on Oct 19 2006, 03:06 PM, said:

As it was already explained it seems to be not possible to force Windows setup to use LFN.

Just one idea that might work - untested:

1. Create "C:\Long Windows Directory" directory before starting setup. SFN will be "LONGWI~1"

2. Ask Windows Setup to use "LONGWI~1" directory

Will it work?

Petr
This works, because it downgrades the LFN to a supported SFN [tilde + 1, tilde + 2 etc...].
But the orignal LFN will be lost.
So it's back to square 1. ;-(


M$ Windows all editions/builds cannot use LFN for install folder name.

This is because the OS loader has to recognize and use the install folder before the LFN component has a chance to load.
This is valid even for NTx OSes, because they too load on top of a stripped-down boot loader, without LFN support.
LFN support component must load later in the sequence.

This post has been edited by MDGx: 19 October 2006 - 04:52 PM


#14 User is offline   oscardog 

  • Member
  • PipPip
  • Group: Members
  • Posts: 234
  • Joined: 29-June 06

Posted 19 October 2006 - 05:40 PM

2) I have also discovered something weird. So, I've performed a fresh, clean install of Win98se with absolutely no updates or fixes. And the weirdness is the OS seems to want to store its Autoexec.bat file on the C drive rather than on the D drive which is what I expected. I use the autoexec.bat file to perform some Real DOS file replacements that you can't use the wininit.ini method for (ie Copy2Gb) and it took a few minutes to realise why it wasn't working because the code was looking for an autoexec.bat file on the d drive when its on the C drive ... Anyone know why this is?

In such circumstances I use subst.exe for drive substitution c: ==)e:, takes care of a lot of os boot/file dependency problems. lfn after install I adapt the folders with no spaces, program folders, start menu etc to bypass any lfn restrictions and win9x adjusts.
Keep up the good work, all the best

#15 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 19 October 2006 - 07:19 PM

wow, heaps of feedback and help! you guys rock ...

Another question:

In Windows 98, how can you determine if the OS has been installed on a laptop computer? It should be easy I would imagine, I just don't know ... are there files that get used only on a laptop? or can we determine this some other way?

The reason is I want the autopatcher to only install laptop updates on computers that are laptops. People with desktops i imagine will feel that installing those updates is pointless and a waste of space, so if its easy to determine this, I will add this check.

Thanks in advance!

#16 User is offline   Petr 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 981
  • Joined: 15-April 05
  • OS:98SE
  • Country: Country Flag

Posted 20 October 2006 - 12:01 AM

View Postsoporific, on Oct 20 2006, 02:19 AM, said:

In Windows 98, how can you determine if the OS has been installed on a laptop computer? It should be easy I would imagine, I just don't know ... are there files that get used only on a laptop? or can we determine this some other way?

Do you know anything what is specific to laptop computers? I.e. something that all laptop computers have and all desktop computers don't have? I don't think so.

Petr

#17 User is offline   Petr 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 981
  • Joined: 15-April 05
  • OS:98SE
  • Country: Country Flag

Posted 20 October 2006 - 01:16 AM

View PostMDGx, on Oct 19 2006, 11:48 PM, said:

This works, because it downgrades the LFN to a supported SFN [tilde + 1, tilde + 2 etc...].
But the orignal LFN will be lost.


I just tried the a.m. procedure and not only that the LFN was not lost but even Windows 98 SE setup has converted SFN to LFN at some stage. The result is working Windows installed in "C:\Long Windows Dir\". The only problem during setup was that java package failed to self-register, but who needs old MS Java now?

I had no time to test it deeper but as general concept it can be apparently used.

It change nothing on the fact that it would be much better and more reliable to use SFN Windows system directory.

Petr

#18 User is offline   oscardog 

  • Member
  • PipPip
  • Group: Members
  • Posts: 234
  • Joined: 29-June 06

Posted 20 October 2006 - 06:41 AM

View Postsoporific, on Oct 20 2006, 02:19 AM, said:

wow, heaps of feedback and help! you guys rock ...

Another question:

In Windows 98, how can you determine if the OS has been installed on a laptop computer? It should be easy I would imagine, I just don't know ... are there files that get used only on a laptop? or can we determine this some other way?

The reason is I want the autopatcher to only install laptop updates on computers that are laptops. People with desktops i imagine will feel that installing those updates is pointless and a waste of space, so if its easy to determine this, I will add this check.

Thanks in advance!

A rough check is to look for the presence of PCMCIA key in the registry and counting the number of subkeys, this can help to differeniate between a laptop and desktop. On desktops there are no subkeys, on laptops there are subkeys for each enabled PCMCIA slot.
Checking also for multiple hardware configurations created if the laptop has a docking port etc can also be examined to narrow false positives.
Lastly if you fancy diving into WMI, you will be able to discover the machines chasis type via its object browser

#19 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 8,792
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 20 October 2006 - 09:43 AM

soporific said:

In Windows 98, how can you determine if the OS has been installed on a laptop computer? It should be easy I would imagine, I just don't know ... are there files that get used only on a laptop? or can we determine this some other way?


Hmmm, it shouldn't be difficult:

[BEGIN SARCASM]
Just use this batch file:
 
@ECHO OFF
ECHO
ECHO Pull off the PC mains plug NOW!
PAUSE
CLS
ECHO If you see this message, it means that:
ECHO 1) You (wisely) did not do what you were told.
ECHO 2) This computer is a desktop and it is connected to an UPS.
ECHO 3) This computer is a laptop and has a working battery.
ECHO Please consider the above three alternatives and judge yourself which one is the
ECHO MOST probable one.
 


:D :D :D

[/END SARCASM]

Now, seriously, you can check for the laptop PCMCIA, as already suggested, here is some code:
http://techsupt.winbatch.com/webcgi/webbat...ct~a~Laptop.txt

jaclaz

This post has been edited by jaclaz: 20 October 2006 - 09:43 AM


#20 User is offline   soporific 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 705
  • Joined: 12-June 05

Posted 20 October 2006 - 11:20 PM

View Postjaclaz, on Oct 21 2006, 01:43 AM, said:

Hmmm, it shouldn't be difficult:

[BEGIN SARCASM]
Just use this batch file:
 
@ECHO OFF
ECHO
ECHO Pull off the PC mains plug NOW!
PAUSE
CLS
ECHO If you see this message, it means that:
ECHO 1) You (wisely) did not do what you were told.
ECHO 2) This computer is a desktop and it is connected to an UPS.
ECHO 3) This computer is a laptop and has a working battery.
ECHO Please consider the above three alternatives and judge yourself which one is the
ECHO MOST probable one.
 


:D :D :D

[/END SARCASM]

Now, seriously, you can check for the laptop PCMCIA, as already suggested, here is some code:
http://techsupt.winbatch.com/webcgi/webbat...ct~a~Laptop.txt

jaclaz

:D you have a sick sense of humour !! a funny one as well ... thanks for the link ... i adapted the info into a little batch file that simply reports if the computer its run on is a laptop or not. If anyone wants to help me confirm the code, download the attachment and run it. All that happens is a certain registry key, if found, is exported to a text file and the existence of it is checked. This happens 5 times. The text file is deleted afterwards. It runs on any version of windows but i'm particularly interested in the results from Win98 machines, obviously.

EDIT: i've realised the code is only going to be correct for Win98. I may as well make it correct for all the other OSes. Just a sec ...

EDIT: 2 here it is ...

Attached File(s)


This post has been edited by soporific: 21 October 2006 - 08:05 AM


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy