Jump to content

some batch file coding help needed...


Recommended Posts

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

Link to comment
Share on other sites


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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Edited by jaclaz
Link to comment
Share on other sites

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 ...

Check_For_Laptop.zip

Edited by soporific
Link to comment
Share on other sites

got some more brain teasers... :sneaky:

* when you install hotfixes manually, a lot of the time in Windows 98se you are asked to reboot the computer so the OS will use the new system files. My question is this:

- what exactly is happening when the system needs to reboot to complete an install. ie what tasks are set to complete on reboot, and how are they carried out ... just the abstract of the process, not the nitty gritty.

- can you "stack" up installing hotfixes that would normally ask you to reboot after each one? I know its possible in lots of cases, but I want to know what the restrictions are ... ie if there are 2 hotfixes with different versions of the same file, do they need to be installed separately? Is there a limit to the number of hotfix installs you can "stack up" before rebooting?

* under what circumstances can you install Dial-Up Networking 1.4 on Windows 98 se ?

- it obviously installs onto a clean install of Win98 with no updates yet installed, but ...

- at some stage, you get a message saying "This update was not designed for your version of Windows"

- when does this happen? The only clue I have so far is that it might be when you install the dsclient update that it happens, but that's a wild guess at this stage.

EDIT: well I can't replicate the "This update was not designed for your version of Windows" message, but I did notice that it produced a boot up error (can't find ndiswan.vxd - your system.ini file refers to a file blah blah blah) - but that was possibly my fault - I'm testing again

EDIT2: no bootup error, but it still won't install nicely --- it does on a perfectly clean Win98 installation, but if I try to apply the update after everything else, I get problems ...

- seems liek the easiest thing is to repackage the hotfix, but not sure how to go about doing this with the file in question (Dial-Up Networking 1.4 on Windows 98 se) - any help much appreciated.

* And what's up with the kb892211 Web folders update? The bloomin thing wants to automatically reboot when I don't want it to!! I am using the /Q:A /R:N switch but it obviously doesn't work.

thanks in advance for help --- the honour roll of people I have to thank for helping with the autopatcher is slowly growing ... :)

Edited by soporific
Link to comment
Share on other sites

- what exactly is happening when the system needs to reboot to complete an install. ie what tasks are set to complete on reboot, and how are they carried out ... just the abstract of the process, not the nitty gritty.

Basically some settings in the Registry must be changed.

You can shave off some reboot time by NOT rebooting but rather terminating the shell (exiting to MS-DOS) and restart it with the command line WIN command.

Moreover, most of the time you don't really need to re-start/re-boot for each install, you can install a number of things and unless one depends on another one a single re-start/re-boot will be enough to update all chnges in one round.

Of course on some install this will not work beacuse in some instances a "real" re-boot is needed.

The install programs can rely on various ways to complete install:

1) Autoexec.bat (in this case a re-boot is mandatory)

2) Wininit.ini

3) Winstart.bat

4) Registry keys, in HKLM or HKCU, typically:

4.1) Runonce

4.2) RunServices

4.3) Runex

5) The StartUp group, or All User Startup

More details here:

http://users.iafrica.com/c/cq/cquirke/startup.htm

Link to comment
Share on other sites

Basically some settings in the Registry must be changed. <snip>

Thanks for the info!

Just letting people know: I posted a link to a file version checker a couple of weeks ago on this thread, but it was a big mistake going with it. When using it, it seemed that you couldn't grab the file version number from a VXD file because it wasn't a system library file but a device driver file. But you can. Gape's unoffical service pack uses GETVER which only produces one line of text: the file version, and the name of the file. Much much easier to use for checking purposes. I don't know where to get it without getting the Unofficial sp2 but at least you know its in there.

So, this means all my checking code is going to change!! No more using file dates!! Yay!!

Link to comment
Share on other sites

Gape's unoffical service pack uses GETVER which only produces one line of text: the file version, and the name of the file. Much much easier to use for checking purposes. I don't know where to get it without getting the Unofficial sp2 but at least you know its in there.

You can get it here: http://thunder.prohosting.com/~ladi/e_cmd32.html#getver

Other utility is Microsoft's FILEVER, it provides a bit more details including language version.

Petr

Link to comment
Share on other sites

Gape's unoffical service pack uses GETVER which only produces one line of text: the file version, and the name of the file. Much much easier to use for checking purposes. I don't know where to get it without getting the Unofficial sp2 but at least you know its in there.

You can get it here: http://thunder.prohosting.com/~ladi/e_cmd32.html#getver

Other utility is Microsoft's FILEVER, it provides a bit more details including language version.

Petr

I seen to get filetype not allowed from the server, http://lbrisar.htmlplanet.com/e_cmd32.html seems to download,scan and work ok. Thanks for the heads up Petr

Link to comment
Share on other sites

oohh got a good one...

consider the following code:

@echo off
:: tests for the location of the windows directory
:: this code works as expected.
IF %windir%==C:\Windows goto END
Echo. the windows directory is not in the default location.
PAUSE
CLS
EXIT

:End
Echo. the windows directory is in the default location.
PAUSE
EXIT

and ...

@echo off
:: write the letter 'Y' to a file called MyFile.txt
:: this code works as expected.
Echo Y> "C:\MyFile.txt"
EXIT

My question is this: for people that understand batch file programming, what would you expect the following code to do? (n.b - It is example code, it has no relation to any of my projects!) --- see if you can work it out without actually trying out the code for real --- and then test it. Or just test it anyway to see the result if you have no idea!

:: this code is designed to test that
:: 2 directory locations match up
:: write Y to a file if they do match
::
<snipped> it was a red herring!!!

@echo off
SET mydir=C:\notexist
IF EXIST "C:\MyFile.txt" DEL "C:\MyFile.txt"
IF %mydir%==C:\exist Echo Y> "C:\MyFile.txt"
IF EXIST "C:\MyFile.txt" goto END
Echo. the directories do not match up
PAUSE
CLS
EXIT

:End
Echo. the directories do match up
PAUSE
EXIT

So, who can guess what happens? And don't just guess, tell us why you think your guess is correct!! And no cheating!! :P

Of all the bugs I've had trouble digging out, the one caused by the above code was the most amazing when I realised why it was happening, because IMHO it was so easy to make the mistake. I've had code that had this bug that I just gave up trying to work out why it wasn't working, and just tunnelled around it. So I thought it may be good to see if I'm the only one or if this is a common misconception.

Edited by soporific
Link to comment
Share on other sites

Easy mistake to do when if == (strings) and not error levels.

IF (pardon the pun) of any use

IF NOT EXIST C:\exist\nul.ext GOTO End

IF NOT EXIST C:\notexist\nul.ext GOTO End

Echo. the directories do match up

PAUSE

CLS

EXIT

:End

Echo. the directories do not match up

PAUSE

EXIT

Link to comment
Share on other sites

Easy mistake to do when if == (strings) and not error levels.

Sorry, i wasn't clear enough. The example code is ONLY to expose the bug. My point is that there is (always) a temptation to try to save extra lines of code than necessary ... ie to be elegant

(method1)
IF [logical test] then [do something]
:Continue

(method2)
IF [logical test] then goto [somewhere]
goto CONTINUE

:[somewhere]
[do something]

:Continue

You would ALWAYS want to use the first method because its less code and less directional label parsing. So you CAN use method1 in all cases EXCEPT when [do something] involves writing to a file - then the bug appears. So, my point is that as it wasn't immediately obvious you couldn't write to a text file as a result of a IF logical test - i was wondering if this had happened to any others ...

I admit to adding a red herring when I wrote:

:: if for some unlikely reason "C:\notexist" or "C:\exist" already exist on your test system

:: change this to something else, and then change the code appropriately

but that was from an earlier version of the test that I forgot to delete (it was only comment anyway) but it did serve to confuse you about the point i was trying to make. Now things should be clear ...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...