Jump to content

What self extractor won't stop batch file execution?


bizzybody

Recommended Posts

I need to copy several self extracting archives from a DVD-ROM to hard drive, execute each archive to extract the file (one big file per archive) to the same folder the archive was copied to, then delete the archives.

REM copy the program's files and folders to C:
MD C:\test
XCOPY install C:test /e

REM copying the Desktop shortcut
REM need to find how to detect XP or Vista and send this to the right place. Easier to have four batch files?
COPY program.lnk C:\Documents and Settings\All Users\Desktop
REM COPY C:\users\public\public desktop

REM copying the files to C:
COPY *.exe C:\test

REM extracting then deleting the archives
C:
CD test
archive1.exe
archive2.exe
archive3.exe
archive4.exe
archive5.exe
archive6.exe
DEL C:\test *.exe /y

The installation path information cannot be in the archives because I'm going to have two batch files, one to install to C: and one to install to D: and these archives almost fill a DVD-R. (The D: version has the shortcut archived and the copy/extract/delete section at the end 'cause I don't know how to return to a removable drive that could be any letter.)

The self extracting archive must either silently extract to the directory they're in, or they must have a command line switch to tell where to extract, and they must NOT stop the batch file from continuing.

I've tried making SFX versions with WinRAR, but when the first one extracts, it ends the batch file execution. Everything else in this batch file works as it should.

Link to comment
Share on other sites


Why you need a self-extractor which won't stop batch-file execution?

This is really necessary because you need to delete the files after they where extracted.

It sound very strange what you are doing (e.g. same archives for different drive-letters) - can you explain more?

--> I'm sure that there are better ways.

Here are some hints:

REM copying the Desktop shortcut

REM need to find how to detect XP or Vista and send this to the right place. Easier to have four batch files?

COPY program.lnk C:\Documents and Settings\All Users\Desktop

REM COPY C:\users\public\public desktop

Simply use

COPY program.lnk "%ALLUSERSPROFILE%\Desktop"

Why do you copy shortcuts? There are a lot of scripts an tool which can create them.

The installation path information cannot be in the archives because ...

Why not use 7-zip (7za.exe as standalone-version), create a simple zip-file instead of an sfx-archive and call something like this in your batch-file

7za.exe x -y -o"YourTargetFolder_Maybe_C_or_D_or_any_other_drive" "path_to_zip\archive1.zip"

cause I don't know how to return to a removable drive that could be any letter

Try this

REM change to C:\test
PUSHD %SystemDrive%\test

REM do something

REM go back to the last directory
POPD

Al

Link to comment
Share on other sites

I want to compress as few things as I can, just so it'll fit on a single layer DVD-R. I've found it's faster to copy the archives to the hard drive then delete them after extracting than it is to extract directly from the disc.

I figured it'd be simplest to pre-create the shortcuts, which need additional commands added and the icon changed from the one in the .exe to one from an .ico file.

I'll look at that Inno setup thing too.

Link to comment
Share on other sites

Got it solved. :)

I used the Windows console SFX instead of the Windows GUI SFX option and tagged them with the silent scripting option.

Then I discovered that the /Y switch for the DEL command has been removed, (it has been quite a while since I've done anything with batch files) which is why the batch file was quitting after the archives all extracted. DEL *.exe /Q /F Quietly deletes them while Forcing the deletion of read only files, in case the copy process doesn't remove the read only attribute. (One of the things I like about XP and Vista, but they don't *always* do that when copying from read only media.)

Here's the two batch files now. (File and folder names changed 'cuz nobody needs to know exactly what I'm installing.)

Install to C.bat

@ECHO OFF
ECHO Copying the program files and folders to C:
MD C:\test
XCOPY install C:test /e

ECHO Copying the Desktop shortcut
COPY PROGRAM.lnk "%ALLUSERSPROFILE%\Desktop"

ECHO Copying the resource files to C:
COPY *.exe C:\test

ECHO Extracting then deleting the archives
C:
CD test
archive1.exe
archive2.exe
archive3.exe
archive4.exe
archive5.exe
archive6.exe
DEL *.exe /Q /F

Install to D.bat

@ECHO OFF
ECHO Copying the program files and folders to D:
MD D:\test
XCOPY install D:test /e

ECHO Copying the resource files to D:
COPY *.exe D:\test

ECHO Extracting then deleting the archives
D:
CD test
archive1.exe
archive2.exe
archive3.exe
archive4.exe
archive5.exe
archive6.exe
DEL *.exe /Q /F

ECHO Copying the Desktop shortcut
COPY shortcutD.exe "%ALLUSERSPROFILE%\Desktop"
C:
CD "%ALLUSERSPROFILE%\Desktop"
shortcutD.exe
DEL shortcutD.exe /Q /F

Simple, short, takes up practically zero space, easy to edit in case I want to make an option to install to E: or any other drive. I had a look at Inno and Nullsoft installers, too much complication for this simple copy, extract, delete operation. No Registry changes nor any alterations to existing files, just a workaround to annoyingly overpriced DVD9 media.

P.S. Are you pleased that instead of just posting "I got it figured out!" I posted EXACTLY HOW I got it to work? :hello: Nothing quite so @#%@%#% as when someone has the exact same problem I'm having with a PC, then at the end of a long thread says "I fixed it!" but doesn't say HOW. (Makes me want to smack them around a bit for being such selfish gits. :realmad:)

Edited by bizzybody
Link to comment
Share on other sites

Well, I thought I had it figured out.

I just tried the D: version and it was all going along just fine, copied the archive .exe files and extracted them.

Then when it ran this command

DEL *.exe /Q /F

It deleted ALL the files, not just the .exe files! How the HELL does that happen?! The extracted files have a different filename extension. Only the DEL . or DEL *.* commands should be able to do that.

I don't know if it ever got around to copying the shortcutD.exe and extracting it, the shortcut didn't appear on the desktop. I did test that bit on its own on a different PC running XP.

The C: version is for use on PCs with bigger drives. The D: version is primarily for a box with a pair of 9.1 gig Ultra/Wide SCSI drives and this software is all it will be running, extremely stripped down with nLite XP, which can run this software just fine.

I'm doing this install deal (along with an unattended XP disc, which has worked quite well) to 'id*** proof' a reinstall in case some clever monkey user figures out how to get into things and foul it all up.

Looks like I'll have to include a DEL command for each and every file by full name.

Link to comment
Share on other sites

A single Visual Basic Script (.vbs) can do everything you want with your sfx files, even create all your shortcuts with parameters and custom icons, and VBS is a lot more powerful than batch file scripting.

.vbs files can even self-delete since they are run entirely from ram, unlike batch files.

There's plenty of resources out there on the subject, so do a little research and you will quickly figure it out. I use .vbs scripts to configure my start menu and quicklaunch and I figured it out in maybe an hour, with a little trial and error and google.

Be sure you have the Windows Scripting Host (WSH) installed.

Here's a good resource on vbs:

http://msdn.microsoft.com/en-us/library/ms950396.aspx

Link to comment
Share on other sites

A single Visual Basic Script (.vbs) can do everything you want with your sfx files, even create all your shortcuts with parameters and custom icons, and VBS is a lot more powerful than batch file scripting.

.vbs files can even self-delete since they are run entirely from ram, unlike batch files.

There's plenty of resources out there on the subject, so do a little research and you will quickly figure it out. I use .vbs scripts to configure my start menu and quicklaunch and I figured it out in maybe an hour, with a little trial and error and google.

Be sure you have the Windows Scripting Host (WSH) installed.

Here's a good resource on vbs:

http://msdn.microsoft.com/en-us/library/ms950396.aspx

Yah, but the stripped down XP box isn't going to have Windows Scripting Host installed, it won't even be on the custom XP install CD.

Second time around, I redid the batch files to delete each archive by full file name after each one is extracted, (takes less room than extracting them all THEN deleting) and just stuffed the shortcut for D: install into its own folder and it worked perfectly. I still want to know WTH caused a command to only delete EXE files to delete ALL the files in the folder and why it then killed the batch instead of doing the copy/extract/delete for the D: install shortcut.

.vbs files can even self-delete since they are run entirely from ram, unlike batch files.

Why would I want it deleted??? It wouldn't be copied to the hard drive, just like the batch files aren't. They simply copy the files to their proper locations, command the self extracting archives to extract themselves, then command the OS to delete those archives.

Completely un-needed complexity for this particular install! I have it working where it's completely non-dependent on any specific thing (like WSH) being present on the PC, aside from Windows XP or Vista itself and whichever things like DirectX or .NET may be required by the software AFTER it's installed.

Once I got the steps sorted out, batch files are the *least complex* and *easiest* method for this specific use. With pre-made shortcuts, it does not depend on Windows having whatever some extra software requires in order to create them on the fly. Anything else would be using a hammer to swat gnats. ;)

This works and I've tested it a few times now and it looks to be 100% foolproof. The satisfaction of making it work, combined with the feeling of "more work than fun" that caused me to give up on writing software around 15 years ago. (I said I hadn't done this sort of thing in a while...)

With this out of the way, I still need to modify a BIOS, create a custom screensaver, desktop wallpaper and do a Windows sound theme... Lots to do but fortunately some months to do it in. At least there's just the ONE PC this year instead of the eight I had to do on short notice last year, though those didn't have any custom stuff like this one.

Link to comment
Share on other sites

Yah, but the stripped down XP box isn't going to have Windows Scripting Host installed, it won't even be on the custom XP install CD.
.vbs files can even self-delete since they are run entirely from ram, unlike batch files.

Why would I want it deleted??? It wouldn't be copied to the hard drive, just like the batch files aren't. They simply copy the files to their proper locations, command the self extracting archives to extract themselves, then command the OS to delete those archives.

I was simply pointing out another option (a much simpler one in my opinion) and showing a few of the pluses of vbs. The Windows Scripting Host has been part of Windows since Win98, so you already have it, even on a stripped down install. WSH allows you to do so much more than any batch files will allow, and you aren't stuck with simple dos commands and batch file limitations.

Dos commands and batch files are handy on occassion though. I still use the cmd prompt for a few things that any Windows version including Vista has never been able to do without 3rd party software.

It's been my experience that people tend to make things much harder on themselves than they need to be, usually because they get used to doing something one way and then refuse to change because they get comfortable. I'm guilty of it myself.

Link to comment
Share on other sites

I was simply pointing out another option (a much simpler one in my opinion) and showing a few of the pluses of vbs. The Windows Scripting Host has been part of Windows since Win98, so you already have it, even on a stripped down install.

Not on any Win98 I've ever installed. I always do a custom install and uncheck WSH. Too many ways for malware to use it, despite all the security patches.

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