Well, it happened. Upgraded to Windows 95. So far most of my old batches seem to work fine. Except SFT.BAT - expected that, it was a neat hack while it lasted, and CHKINT.BAT - win95 changes interrupts about every boot. I'll update bugs as I find them and maybe add a few new batches as I figure out how to get my work done again.
This page is for helpful batch files that make my life easier under Windows 95, but there is nothing really 95-specific about them. They should work fine under Windows 3.1 but they are mainly for addressing little things that used to be so easy, like launching a dos prompt in the directory I'm in or even just zipping files. I have a batch that unzips whatever is dropped to it into a directory with the same name as the zip, it'll show up here when I clean it up.
Here is a cool batch that zips up files dragged to it, unfortunately command-line length limits it to just a few files at a time. Still gets the job done, keeps adding to whatever zip is in the current directory, or new.zip if no zip file is present. Put it on the desktop to make the zip there, or if using a shortcut set the starting directory to the desktop (or anywhere else you want the zips to show up at). Updating zips is easy, just drag the zip to update to the desktop then drop the files to add on the batch file or shortcut. Here it is...
:: drag and drop files to add to a zip file - only works :: if a few files are dropped, don't get carried away :: adds to the last zip in current, otherwise creates NEW.ZIP @echo off echo. echo Funky drag-n-drop Zipper echo ======================== echo. set zipname=NEW.ZIP for %%a in (*.zip) do set zipname=%%a :loop if .%1==. goto done echo Adding %1 to %zipname% >nul pkzip %zipname% %1 shift goto loop :done echo Done. set zipname=
If you drag too many files to it, you'll get a command prompt instead, just drag two or three at a time. If you need to zip a lot of files better just fire up a dos prompt, but I immediately grew tired of having to cd to my working dir etc just to zip up a file because explorer has no stupid run command.
Having to put a dos shortcut for every directory I might care to run a dos prompt in is inconvenient, having to make batches like the ZIPPER.BAT above for every command is a lot of work. The "command prompt here" explorer option is cool when the directory is visible, if not you have to back out and find where you were again to launch the prompt. Surely there is a simple answer to what used to be file|run... there is. A batch that takes the first parameter and strips off everything after the last "\" and uses it to launch a prompt in that directory, just drop any file or directory on the icon and it puts you there, very nice! Even work with long directory names, that surprised me. You'll need the QBASIC.EXE file to run this, enjoy...
:: Place a shortcut to this on the desktop, then drag a :: file or directory to it to launch a dos prompt there. :: (c)1997 by Terry Newton, requires QBasic. @echo off ::-- set up temp dir set tfd=%tmp% if not exist %tfd%\nul set tfd=c: ::-- distiguish between no parm, file or dir set par=%1 if .%1==. set par=c: if exist %par%\nul set par=%1\ ::-- make and run temp qbasic program... ::--- strip everything after last "\" echo>%tfd%\setd$.bas par$="%par%":ptr=len(par$) echo>>%tfd%\setd$.bas lp:if mid$(par$,ptr,1)="\" then goto ok echo>>%tfd%\setd$.bas ptr=ptr-1:if not ptr=0 then goto lp echo>>%tfd%\setd$.bas ok:dir$=left$(par$,ptr) echo>>%tfd%\setd$.bas if not right$(dir$,1)="\" then dir$=dir$+"\" ::--- if invalid dirname, change to c:\ instead echo>>%tfd%\setd$.bas if dir$="\" then dir$="c:\" echo>>%tfd%\setd$.bas if not mid$(dir$,2,1)=":" then dir$="c:\" ::--- write batch that changes drive\directory echo>>%tfd%\setd$.bas open "%tfd%\setd$.bat" for output as #1 echo>>%tfd%\setd$.bas print #1,"@echo off" echo>>%tfd%\setd$.bas print #1,dir$:print #1,"cd ";dir$ echo>>%tfd%\setd$.bas print #1,"echo." echo>>%tfd%\setd$.bas close #1:system qbasic /run %tfd%\setd$.bas ::-- shell to change batch and stay until "exit" command /e:4096 /k %tfd%\setd$.bat ::-- remove temp files and clean up if exist %tfd%\setd$.ba? del %tfd%\setd$.ba? set par= set tfd=
Ok, here it is, the UnZipper batch... put a shortcut to this on the desktop then you can drag zips to it and they magically unzip into individual folders. Not too many at once, same command-line-length limits. If run without parameters, it unzips everything in the starting directory that is specified in the shortcut.
:: A batch that unzips files dropped onto it :: If no parms, unzips all zips in the current dir :: (c)1997 Terry Newton, requires QBasic @echo off if .%1==.Unzip goto %1 set batch=%0 echo>unext$.bas :on error goto X echo>>unext$.bas open "unext$.tmp" for input as #1 echo>>unext$.bas open "unext$.bat" for output as #2 echo>>unext$.bas input #1,a$:print #2,"set dirname=";:p=1 echo>>unext$.bas L:q$=mid$(a$,p,1):if q$="." then goto X echo>>unext$.bas print #2,q$;:p=p+1:if not p=len(a$) then goto L echo>>unext$.bas X:close #1:close #2:system if .%1==. goto noparms :parse if .%1==. goto done call %batch% Unzip %1 shift goto parse :noparms for %%a in (*.zip) do call %batch% Unzip %%a goto done :Unzip echo %2>unext$.tmp qbasic /run unext$.bas call unext$.bat echo Unzipping %dirname%... md %dirname% pkunzip %2 %dirname% -d -o >nul goto end :done del unext$.bas if exist unext$.bat del unext$.bat if exist unext$.tmp del unext$.tmp set batch= set dirname= :: add scanner stuff here :end
In the command prompt batch I had to use the TMP directory to keep the temp files from popping up on the desktop and distracting me. This one just does it in the current, wherever that is (with Windows it is hard to tell sometimes). Adjust if you want, but Windows usually isn't fast enough to show them unless unzipping something big, then who cares since they go away. Prompts are different...
Here are all of these batches in a zip file. (that was easy! much better.)
Registry Tricks... If you're familiar with such things here's a neat trick... look under HKEY_CLASSES_ROOT and look for the "*" key, then under that the "shell" key - it's all the options that appear for all files when right-clicked. Keys added under "shell" are for the menu options (& specifies the shortcut letter, as in "Note&pad", the key itself can be named anything) and under each added key should be a "command" key with the actual command (something like "notepad.exe %1"). In no time I added right-clicks for my common browsing utilities and much to my pleasure my ComHere.bat file. Now I can right click on anything and get a command prompt, the Command Promt Here power-toy handles the directories and ComHere for going to the same directory a file is in. Now I'm happy, much easier than dragging to the icon.
Be sure to make backup copies of SYSTEM.DAT and USER.DAT before making any registry changes, one bad move could result in a non-functional or badly behaving operating system. Editing the registry is not for the beginner, but then again, neither is most of this stuff.
After living with Windows 95 for a couple of weeks...
It ain't so bad. I will be much happier when I get my display adapter replaced, Windows 95 doesn't like my ET4000 card when running Dos programs and tends to smear garbage outside the window. Sometimes it gets really bad, to the point I have to Alt-Enter to pop it full screen and back again to fix things. It's something buggy in the card itself, had the same problem with 3.1 but found that disabling background processing made the effect go away. This helps a little under 95, but the screen still often falls apart when I run Dos programs. Hopefully this will go away forever with a new video card.
It did - got a S3 velocity something and now my dos kicks! I've got evolving warriors growing in the background and able to edit this at the same time and it's still faster than the old card was unloaded. But in trade for usable dos windows I get a new set of feature-bugs, like crashing and burning when exiting Windows and strange sounds coming from my monitor. As long as I don't use any of the fancy stuff it works fine.
For the most part Win95 batch is very compatible with Dos 6 batch (even LIFE.BAT works). Except for a few utility batches, I haven't had to re-write anything except for stuff I already fixed a while back when I found out Win95 doesn't process the line "echo on error goto line > file" correctly, changed to "echo :on error..." to fix. Win95 doesn't support the "for %%a in (/ab) do" trick, but I never use that one so I don't care. Here's an irritating one - DIR /B returns long filenames. Only some of the new dos commands accept long filenames and the spaces make the filenames appear as separated parameters, so this is definitely a problem. Especially for sweep batches, they can't access directories with long names. The stock Win95 installation is missing loadfix, qbasic and a few other commands, but the old Dos 6 files works fine, and they can be download from Microsoft's web page. To make things simpler I made a c:\dos directory containing a copy of loadfix.com and a couple of other files for the few batches that look there specifically.
Update... There are ways to control long/short filename generation in Windows 95. For filenames created via the FOR command, use the LFNFOR ON and LFNFOR OFF commands before the FOR command. Thanks to Tom Lavedas credits Charles Dye for pointing this out. Another great tip came to me via email from Mark Young - to get the DIR /b command to return short filenames rather than long, use DIR /z/b instead, using the undocumented /z switch.
Well, after a few months of 95ness everything seems to be ok, no major glitches. All three batches are still in-use, but I finally had to get a Windows zip-file manager to deal with archives that contain files with long filenames. I chose PowerZip because it was free. I still leave zip files associated with the dos AVIEW program, since viewing files in PowerZip really runs them, not very good for checking out new stuff. To get rid of all the extra registry stuff added by PowerZip (don't need it) I restored my registry after installing, then added a new entry for zip files to open it in PowerZip, just double-clicking a zip opens it in the much safer but non-LFN-compatible AVIEW program. [note 4/24/00 - version 3.6 was ok but don't be tempted by the new Lite 2000 version, it installs "aureate spyware" so that it can download ads even when you're not using the software... a disturbing trend these days. Just Say No to Spyware!]
Dealing with the registry was one of the hardest things to get used to, everytime I'd get it set up like I like some application I'm installing stomps out my associations. Irritating to say the least. There are also those times when Windows falls down and will boot but in a degraded state, like icons that no longer stick. I hate that! While rather large shareware and freeware utilities exist to back up the registry, they typically make a complete copy of the file, gobbling up more than a meg with each backup. To make life easier for me, I made a batch that saves and restores the registry and critical system files to and from a compressed zip archive using PKZIP and PKUNZIP. Much better. Now I save just before installing anything that might be an annoyance, if it goes bad I can restore the previous setup without thought. If I think I might need to keep a previous configuration, I just rename the archive file. This program has saved me untold nightmares, but it should be noted that restoring partially wipes out anything that was installed since the last save, and if programs were uninstalled after saving, their settings will be restored with possibly non-functional results. There is no undo but you can simulate one by renaming the regsaver.rzf save file, save the setup and rename that one to something else, then renaming the original save file back to regsaver.rzf and restoring.
Since this involves tricky stuff and if misused could cause data-loss, I'm only posting the text. Pay particular attention to the comments. Use the following program at your own risk, but if you make manual backup copies of your registry files (SYSTEM.DAT and USER.DAT) before testing the first time you should be safe enough. If you've made it this far, you should know how to use attrib and copy, or use a reliable sysfile backup program like Microsoft's ERD before attempting to use this. This batch was made to be a convenience, to reduce multiscreen wizards to a single click to encourage myself to save often.
Name REGSAVER.BAT in C:\WINDOWS ---------------------------- start cutting --------------------------- :: Win95 Registry Save/Restore/Compact Utility Batch :: Requires PKZIP.EXE and PKUNZIP.EXE on the path :: Compact option requires updated osr2 regedit.exe OR ELSE, :: please read notes below before using. :: :: This batch archives the SYSTEM.DAT, USER.DAT, SYSTEM.INI, :: WIN.INI and CONFIG.SYS files to REGSAVE.RZF, permitting them :: to be restored in those freaky moments after doing something :: that blew your configuration. Best to put this batch in :: C:\WINDOWS but can be anywhere convenient for running. :: :: Syntax: (parms must be lower case) :: REGSAVER save - save registry system/win.ini and config.sys :: REGSAVER restore - restores files from last save :: REGSAVER compact - compacts registry (bug alert! save first!) :: :: You can only save while in Windows, make a shortcut for :: saving anytime, something like: c:\windows\regsaver.bat save :: (assuming it's in c:\windows, that's where I put it) Set the :: window property to close on exit to make the window go away. :: :: Note! You MUST restart in real Dos mode (not dos from windows!) :: before using the restore or compact options, or set the shortcuts :: to run in MSDOS Mode. Restoring while in Windows does not produce :: useful results. :: :: WARNING! make sure save and restore works BEFORE trying compact, :: the operation is drastic and CAN CAUSE DATA LOSS! DO NOT TRY :: UNLESS using the newer osr2 version of win95 with the less buggy :: regedit AND there are no control characters in any of the entries :: or if there are, you don't care if the settings are wiped out. :: @echo off ::## change next 2 lines if windows isn't in C:\WINDOWS ## c: cd\windows if .%1==. echo REGSAVER save - save registry system/win.ini and config.sys if .%1==. echo REGSAVER restore - restores files from last save if .%1==. echo REGSAVER compact - compacts registry (bug alert! save first!) if .%1==. echo TYPE REGSAVER.BAT for important notices and instructions attrib system.dat -r -h -s attrib user.dat -r -h -s if .%1==.save echo Saving Registry... if .%1==.save pkzip regsave.rzf system.dat user.dat >nul if .%1==.save pkzip regsave.rzf system.ini win.ini c:\config.sys >nul if .%1==.restore echo Restoring Registry... if .%1==.restore pkunzip regsave.rzf -o >nul if .%1==.restore move config.sys c:\config.sys >nul if .%1==.compact echo Compacting Registry... if .%1==.compact regedit /e regsave.cmp if .%1==.compact regedit /c regsave.cmp if .%1==.compact del regsave.cmp attrib system.dat +r +h +s attrib user.dat +r +h +s ----------------------------- stop cutting -----------------------------
Note that only the save function can be used while Windows is running. ALWAYS exit Windows (or set the shortcut to run in MSDOS mode) for the restore and compact options. Don't use the compact option unless running a newer Win95 AND prepared to restore the registry if something goes wrong. It works well on my system but maybe not yours, I present the information because I had to suffer at the hands of a buggy shareware program that shrouded what amounts to regedit /e, regedit /c in a bunch of send me money mumbojumbo, then when I uninstalled it, it took my whole INF directory with it! Good thing I had tape backups. If this one doesn't work, at least all it'll take out is the registry...