home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
In'side Shareware 1995 April
/
ish0495.iso
/
win95
/
winbatch
/
install.wb_
< prev
next >
Wrap
Text File
|
1995-01-04
|
6KB
|
245 lines
; To actually use and distribute this code as an install program, then either each
; user must have WinBatch installed on their PC, or the WBT file must be compiled
; with the Winbatch Compiler. This sample provided for evaluation only
a1="This is a sample wbt file that shows how to code an install program in WinBatch."
a2="In this code, the 'FileCopy' statements that would do the actual install"
a3="have been commented out, so that you can run this sample to see what a "
a4="Winbatch-based install program might look like without really copying any"
a5="files at all."
a6="It will make a Program Manager group to demo the ability to manage Program "
a7="Manager (or other shell) icons. Just delete the group after the demo."
a1=strcat(a1,@crlf,@crlf,a2,@crlf,a3,@crlf,a4,@crlf,a5,@crlf,@crlf,a6,@crlf,a7,@crlf)
Message("Install-O-Batch",a1)
;Install-o-Batch
;A Winbatch software installer
;this wbt file is designed to be compiled and
;run off of a floppy disk
; Who am us anyways
InstallName="Acme Knickerbockers, Inc."
; Specify default destination directory
DestDir="C:\ACMEAPP\" ; <<< We need and assume trailing \'s
SrcDir="A:\" ; <<< Ditto
; Specify files to install. Start at file 1. No skips in numbers
File1="potatoe.fry" ; CHOOSE FILE 0 so that it HAS AN EXTENSION ( 'fry' in this case )
file2="Carrot.cak"
file3="Peas.pod"
file4="cornbeef.cab"
file5="toast.jam"
file6="readme"
; Now we get busy
gosub SetupSplash
WhereWe=DirGet()
gosub VerifySrcDir
gosub VerifyDestDir
; Figure out how many files we have for user display
for filenum=1 to 1000
if !IsDefined(File%filenum%) then break ; all doned
next
filenum=filenum-1
for i=1 to filenum
src=strupper(strcat(SrcDir,File%i%))
dst=strupper(strcat(DestDir,File%i%))
BoxText(strcat("Installing file ",i," of ",filenum,@crlf,@crlf,"Copying",@crlf,@tab,src,@crlf,"To",@crlf,@tab,dst))
; FileCopy(src,dst,0) ; the commented out FileCopy
Delay(Random(6)+1) ; Fake delay to simulate FileCopy
next
; Set up program group now
; Use the handy progman.wil file
File1="Clock.exe"
File2="Calc.Exe"
Call("progman.wil","AddGroup '%InstallName%'")
Call("progman.wil","AddIcon '%InstallName%' '%File1%' 'Acme Clock'")
Call("progman.wil","AddIcon '%InstallName%' '%File2%' 'Acme Calculator'")
if WinExist("Program Manager") then WinIconize("Program Manager")
Message(InstallName,"Install Complete")
gosub UnSplash
exit
:Cancel
Gosub Unsplash
exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SetupSplash iconizes all windows, remembers current wallpaper
; and installs our wallpaper
:setupsplash
OrigWallpaperName=WinparmGet(10)
OrigWallpaperTile=IniRead("Desktop","TileWallpaper",0)
WallPaper("splash.bmp",1 )
OrigWindowList=WinItemize() ;Get list of all open Windows
OrigWindowCount=ItemCount(OrigWindowList,@tab)
for i=1 to OrigWindowCount
a=ItemExtract(i,OrigWindowList,@tab)
b = WinState(a)
OrigWindowState%i% = b
; Note we could hide the other windows here, but if the install
; bombs kind of bad, it leaves the user in a lurch and they
; got to reboot. Bad news. With icons they can always recover
; by themselves.
if b!=@HIDDEN && b!=@ICON && WinExist(a) then WinIconize(a)
next
WinPlaceSet(@NORMAL,"","300 20 700 220")
BoxOpen(InstallName,"Install Initializing. Please wait")
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;UnSplash undoes Setup Splash
:UnSplash
ErrorMode(@off)
for i= OrigWindowCount to 1 by -1
a=ItemExtract(i,OrigWindowList,@tab)
switch OrigWindowState%i%
case @HIDDEN
break
case @NORMAL
WinShow(a)
break
case @ICON
break
case @ZOOMED
WinZoom(a)
break
end switch
next
ErrorMode(@cancel)
WallPaper(OrigWallPaperName,OrigWallpaperTile)
return;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:VerifyDestDir
BoxText("Verifying Destination Directory")
TryDest=strupper(AskLine(InstallName,"Enter destination directory or accept default",DestDir))
;Make sure there is a \ on the end
a=strsub(TryDest,strlen(TryDest),1)
if a!="\" then TryDest=strcat(TryDest,"\")
;If it exists, go home
if DirExist(TryDest)
DestDir=TryDest
return
endif
; Is user real sure?
a=AskYesNo("InstallName",strcat("Directory ",TryDest,@crlf,"Does not exist. Create Directory?"))
if a==@NO then goto VerifyDestDir
; We have to chop up the directory name and insure each part exists
; and if not, create them one at a time.
Count=1
WorkDir=TryDest
While @TRUE
a=strsub(WorkDir,1,strlen(WorkDir)-1)
DirPart%Count%=FileRoot(a)
;Did unbelievable user specify an extension for the directory???
b=FileExtension(a)
if b!="" then DirPath%Count% = strcat(DirPart%Count%,".",b)
WorkDir=FilePath(a)
if strlen(WorkDir)<=3 then break
Count=Count+1
endwhile
; got all the pieces now, build the directory
for i=Count to 1 by -1
if !DirExist(WorkDir) then DirMake(WorkDir)
WorkDir=strcat(WorkDir,DirPart%i%,"\")
next
;Make final piece
DirMake(WorkDir)
DestDir=TryDest
Return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:VerifySrcDir
BoxText("Verifying Source Directory")
Delay(1) ; remove for production version
return ; remove for production version
SrcDir=DirGet() ; Get current directory.
b=strcat(SrcDir,file1) ; Get file name of first file
while !FileExist(b)
d=strupper(File1)
BoxText("Please select file %d% in source directory%@CRLF%to assist Install-O-Batch in locating source directory.")
b=strcat("*.",FileExtension(d))
a=AskFileName("Please locate %d%","","%b%|%b%|",b,1)
SrcDir=FilePath(a)
b=strcat(SrcDir,file1) ; Get file name of first file
endwhile
return