WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample code
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Setup program for 2002F and newer versions

;FileDelete("c:\wbsetup.txt")
;DebugTrace(@on,"c:\wbsetup.txt")


;Flag Files
;Turn on debugtrace  c:\wbsetup.dbg
;Bypass AppExist     C:\wbsetup.app

if FileExist("C:\wbsetup.dbg") then DebugTrace(@on,"c:\wbsetup.txt")
OnCancel="Exit"
killversion=7          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
killdate="2005:02:14:00:00:00"   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

if param0==1		    ; Stacker bug fix
   if strlower(param1)=="hd" then dskcode=0
   if strlower(param1)=="floppy" then dskcode=1
   if strlower(param1)=="getver"
      wbcver=strupper(Version())
      IniWritePvt("SETUP","WBCBuildVersion",wbcver,"WWW-PROD.INI")
      exit
   endif

   param0=0
endif

dbg=0	     ; Master debug flag to swap directories and do debug stuff

dllcopydebug=0
dbgnocopy=0   ; 1=Prevents real install.  Mostly graphics
dbgnorem=0    ; 1=Prevents real uninstall.  Mostly graphics
dbgsrcpath="..\WBC Disk 1\"	; Source path
dbginfname=strcat(dbgsrcpath,"setup.inf")	  ; Inf File Path
;;;;;;;;DEBUG STUFF ABOVE TIS POINT
if ! IsDefined(dbg) then dbg=0
if dbg==0	  ; make sure debug stuff is off is debug is not set
   dbgnocopy=0
   dbgnorem=0
endif 
IntControl(29, @TAB, 0, 0, 0)	 ;Use Tabs as file delimiters 

;***************LEP ADDED THIS SECTION BELOW************************



whoami=WinExeName("") ; to find out if I'm MAKEICON.EXE, and later use this for UNINSTALL if not
root = strlower(FileRoot(whoami))
ext = FileExtension(whoami)
identity = StrLower(StrCat(root, ".", ext))                                                                                                                   
if identity == "makeicon.exe"
   Display(10, "NOTE: WINBATCH ICONS GET INSTALLED TO YOUR \STARTUP DIRECTORY!!!", "NB: TO RUN MAKEICON.EXE, YOU *MUST* BE RUNNING MAKEICON.EXE%@CRLF%FROM YOUR SERVER'S \WINBATCH\SYSTEM\ DIRECTORY.")
   sayyes = AskYesNo("WinBatch Icon Installation", "Do you want to install or update the WinBatch Icons to your Local PC?")
     If sayyes == @YES then iconsonly=1
     If sayyes == @NO then iconsonly=0
else
     iconsonly=0
Endif


if (root!="makeicon") && (root!="uninstal") && (root!="setup") ; removed 20001209 && (root!="setup16") && (root!="setup32")
   Message("Error","Unrecognisable exe name found.%@CRLF%Cannot proceed.")
   exit
endif


;***************LEP ADDED THIS SECTION ABOVE************************      
;The Setup Program
;Skip over subroutines.  They run just a little faster up front
while @FALSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Subroutines here
:GetIniItem
        inivar=ItemExtract(1,iniitem,":")
        initemp=ItemExtract(2,iniitem,":")
        %inivar%=IniReadPvt(lang,initemp,"XXX",infname)
        if ((%inivar%=="XXX") && (lang!="english")) then %inivar%=IniReadPvt("English",initemp,"XXX",infname)
        inivar=0
        initemp=0
        return

:GetSetupItem
        inivar=ItemExtract(1,iniitem,":")
        initemp=ItemExtract(2,iniitem,":")
        
        if (lang!="english")
            %inivar%=IniReadPvt(lang,initemp,"XXX",infname)
            if %inivar%=="XXX" then %inivar%=IniReadPvt("Setup Data",initemp,"XXX",infname)
        else
           %inivar%=IniReadPvt("Setup Data",initemp,"XXX",infname)
        endif
        inivar=0
        initemp=0
        return

:bbfill
        bigbocks=IniReadPvt(lang,"%bigbocksvar%1","XXX",infname)
        if ((bigbocks=="XXX") && (lang!="english")) then bigbocks=IniReadPvt("English","%bigbocksvar%1","XXX",infname)
        
        bbindex=2
        while 1
           bbx=IniReadPvt(lang,"%bigbocksvar%%bbindex%","XXX",infname)
           if ((bbx=="XXX") && (lang!="english")) then bbx=IniReadPvt("English","%bigbocksvar%%bbindex%","XXX",infname)
           if bbx=="XXX" then break
           bigbocks=strcat(bigbocks,@crlf,bbx)
           bbindex=bbindex+1
        endwhile
        bbx=0
        return

:textfill
        for txtx=1 to 10
           text%txtx%=IniReadPvt(lang,"%textvar%%txtx%","XXX",infname)
           if ((text%txtx%=="XXX") && (lang!="english")) then text%txtx%=IniReadPvt("English","%textvar%%txtx%","XXX",infname)
           if text%txtx%=="XXX" then text%txtx%=""
        next
        textall=strcat(text1," ")
         for txtx=2 to 10
            if text%txtx%=="" then textall=strcat(textall,@crlf,@crlf)
            else textall=strcat(textall,text%txtx%," ")
         next

        return

:dolog
        logflag=0
        ;debug(1)
        if !isDefined(logfile)
           if UseLongNames
                  if iconsonly==1   ;LEP ADDED THIS HERE
                    logfile=strcat(DirWindows(0),inireadpvt("Setup Data","loglong","setup.log",infname))
                  else
                    logfile=strcat(dirsystem,inireadpvt("Setup Data","loglong","setup.log",infname))
                  endif
              ErrorMode(@off)
              loghand=FileOpen(logfile,"APPEND")
              ErrorMode(@cancel)
              if loghand==0 then UseLongNames=0 ; flop over to short names
           endif
           if !UseLongNames
              if iconsonly==1   ;LEP ADDED THIS HERE
                 logfile=strcat(DirWindows(0),inireadpvt("Setup Data","logshort","setup.log",infname))
                 loghand=FileOpen(logfile,"APPEND")
              else
                 logfile=strcat(dirsystem,inireadpvt("Setup Data","logshort","setup.log",infname))
                 loghand=FileOpen(logfile,"APPEND")
              endif
           endif
           logflag=1
        else
           loghand=FileOpen(logfile,"APPEND")
        endif
        FileWrite(loghand,loglog)
        if logflag==1 then FileWrite(loghand,`FILE LOG "%logfile%"`)
        FileClose(loghand)   
        loglog=""
        return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:VDDDEATH
        OnCancel=OldCancel
        return

:VerifyDestDir
        if TryDest==""
           vdddefault=0
           OldCancel=OnCancel
           OnCancel="goto VDDDEATH"      
           TryDest=AskLine(Title,"Enter destination directory or accept default",DestDir)
           if DestDir==TryDest then vdddefault=1
           OnCancel=OldCancel
        else
           vdddefault=1   
        endif   
        
        ;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
           vddstatus=1
           loglog=strcat(loglog,`DIR EXISTS "%DestDir%" already exists`,@CRLF)
           return
        endif
        
        
        ; Is user real sure?
        if vdddefault==1 then goto SKIPPROMPT   ; Skip prompt if accepting default
        OldCancel=OnCancel
        OnCancel="goto VDDDEATH"      
        a=AskYesNo(Title,strcat("Directory ",TryDest,@crlf,"Does not exist.		     Create Directory?"))
        OnCancel=OldCancel
        if a==@NO then TryDest=""
                  then goto VerifyDestDir
        
        :SKIPPROMPT
        ; 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 DirPart%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 iconsonly==0     ; LEP ADDED THIS HERE
               if !DirExist(WorkDir) then DirMake(WorkDir)
                                  then loglog=strcat(loglog,`DIR CREATE "%WorkDir%" `,@CRLF)  
            endif               ; LEP ADDED THIS HERE        
           WorkDir=strcat(WorkDir,DirPart%i%,"\")
        next
        
        ;Make final piece
        if iconsonly==0     ; LEP ADDED THIS HERE
           DirMake(WorkDir)
           loglog=strcat(loglog,`DIR CREATE "%WorkDir%" `,@CRLF)
        endif           ; LEP ADDED THIS HERE
           loglog=strcat(loglog,`FILE FAKE "`,TryDest,`*.BAK"`,@crlf)
           loglog=strcat(loglog,`FILE FAKE "`,TryDest,`*.GID"`,@crlf)
     
        
        DestDir=TryDest
        vddstatus=2
        Return

:CANCEL
        %OnCancel%
        exit
        
end while ; skip subroutines        

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

:BEGINNING
Exclusive(@ON)  ; Try this to speed up install
if IsKeyDown(@SHIFT & @CTRL) then Debug(1)         ; is shift and ctrl down, turn debug on

exename=WinExeName("")                  ;Get our EXE name (returns path to MAKEICON.EXE)
infname=strcat(FilePath(exename),"setup.inf")   ;Get ini file name
if dbg then infname=dbginfname
lang=strlower(IniRead("Intl","sLanguage","enu"))
if lang=="enu" then lang=strlower("English")
iniitem="Title:Title"
gosub GetIniItem
if Title=="XXX"
    Message("Error","The setup.inf file was not found.	The setup program cannot work without it.")
    exit
endif  

if WinExist(title) && param0==0       ; if we are already running and somehow a second copy starts.
   WinActivate(title)
   exit
endif

 


;colors
DKBLUE="0,0,128"
BLUE="0,0,255"
LTGRAY="192,192,192"
GRAY="128,128,128"
DKGRAY="64,64,64"
GREEN="0,255,0"
RED="255,0,0"
DKRED="128,0,0"
BLACK="0,0,0"
WHITE="255,255,255"
YELLOW="255,255,0"
;rects
rectAll=""
rectNormSize="100,100,900,900"
rectTopHalf="0,0,1000,210"
rectBotHalf="0,210,1000,1000" 
rectTitle="100,50,900,200"
rectTitleText="101,0,990,140" 
rectTitleBMP="20,10,100,200" 
TitleHeight=950
rectNote="250,850,750,925"
NoteHeight=400
rectNoteText="70,200,950,800"

rectnoteline1="0,0,1000,0"
rectNoteline2="1000,1000,1000,0"
rectNoteLine3="0,1000,1000,1000"
rectNoteLine4="0,0,0,1000"
notepenwidth=120
rectnoteline1b="40,150,960,150"
rectNoteline2b="960,840,960,150"
rectNoteLine3b="40,840,960,840"
rectNoteLine4b="40,150,40,840"
notepenwidthb=50
rectU="100,775,900,850"
UHeight=400
rectutext="100,100,1000,900"
rectTherm="200,350,800,650"
rectButton="0,0,100,100"
;rectThermDone=`"100,550,%%xxx%%,800"`
;rectThermLeft=`"%%xxx%%,550,900,800"`
rectThermLine1="100,550,900,550"
rectThermLine2="900,550,900,800"
rectThermLine3="900,800,100,800"
rectThermLine4="100,800,100,550"
ThermPenWidth=20
rectThermText1="100,50,1000,199"
rectThermText2="100,200,1000,349"
rectThermText3="100,350,1000,489"
rectThermPercent="490,625,550,725"
topid=1
canid=2
Thermid=3
Noteid=4
WbId=5


;`;`;`;`;`;
;Verify version of Windows and that we know what we are doing
;a=WinMetrics(-4)  ;0=??? 1=Win 2=Win4Wkg 3=Win32S  4=WinNT 5=Win95 6=???
;if a>=6 then a=99
;if (a==0 || a==1 || a==2 || a==3 || a==99)
;   iniitem="x1:sorry"
;   gosub GetIniItem
;   iniitem="x2:wintype%a%"
;   Message(x1,x2)
;   exit                           ;Sorry, no can do
;endif


;Get some common items,  Names of buttons, etc.
iniitem="NextButton:Next"
gosub GetIniItem
iniitem="CancelButton:Cancel"
gosub GetIniItem
iniitem="ExploreButton:Explore"
gosub GetIniItem
iniitem="BackButton:Back"
gosub GetIniItem

NextButtonX=StrReplace(NextButton,"&","")
CancelButtonX=StrReplace(CancelButton,"&","")
ExploreButtonX=StrReplace(ExploreButton,"&","")
BackButtonX=StrReplace(BackButton,"&","")

regname=IniReadPvt("Setup Data","regname","Unknown",infname) ;Get registry name
wash=IniReadPvt("Setup Data","wash",4,infname) ;Get wash color
regsection=IniReadPvt("Setup Data","regsection","Wilson WindowWare",infname) ;Get regsection



if WinMetrics(-4) < 4
   UseLongNames=0
   win32=0
   wincode=16
   REGXROOT=@REGROOT
   REGXCLASSES=@REGROOT
else
   if WinMetrics(-2)==1    ; Ooop  Win16 exe in win32 environ
      Pause("Please note","You are trying to install a 16 bit version of this product in a 32 bit environment.   32 bit versions are available. Do you want to continue?")
      UseLongNames=0
      win32=0
      wincode=16
      REGXROOT=@REGROOT
      REGXCLASSES=@REGROOT
   else
      iniitem="a:UseLongNames"
      gosub GetSetupItem
      if a=="XXX" then UseLongNames=1
      else UseLongNames=a
      if a!=0 then UseLongNames=1
      win32=1
      wincode=32
      REGXROOT=@REGMACHINE
      REGXCLASSES=@REGCLASSES
   endif
endif




BoxCaption(topid,strcat(Title," ",wincode))
colors=WinMetrics(-1)
if colors<20 then colors=0
else colors=wash
BoxColor(topid,BLACK,0)
BoxDrawRect(topid,rectTopHalf,2)
a=DKBLUE  
if wash==1 then a=DKRED 
BoxColor(topid,a,colors)       ;Blue  Gradient
BoxDrawRect(topid,rectbotHalf,2)
BoxesUp(rectNormSize,@ZOOMED)

BoxNew(wbid,rectTitle,1)
BoxColor(wbid,BLACK,0)
BoxDrawRect(wbid,rectall,2)
;BoxPen(wbid,BLACK,1)
BoxTextFont(wbid,"Arial",TitleHeight,170,0)   ; san-srif, ariel, size 20, bold, noitalic
a=BLUE
if wash==1 then a=RED
BoxTextColor(wbid,a)
BoxDrawText(wbid,rectTitleText,regname,0,0)
if iconsonly==0 then BoxBitMap(1,rectTitleBMP,strcat(FilePath(whoami),"WBOwl.bmp"),3)   
  
iniitem="x2:Init"
gosub GetIniItem

BoxNew(Noteid,rectNote,1)
BoxColor(Noteid,LTGRAY,0)       ; Light Gray no gradient
BoxDrawRect(Noteid,"",2)
BoxTextFont(Noteid,"Arial",NoteHeight,0,0)   ; san-srif, ariel, size 12, nobold, noitalic
;BoxTextRect(Noteid,rectNoteText)
BoxTextColor(Noteid,BLUE)

BoxPen(Noteid,WHITE,notepenwidth)
boxdrawline(Noteid,rectNoteLine1)
boxdrawline(Noteid,rectNoteLine4)
BoxPen(Noteid,GRAY,notepenwidth)
boxdrawline(Noteid,rectNoteLine2)
boxdrawline(Noteid,rectNoteLine3)
BoxPen(Noteid,WHITE,notepenwidthb)
boxdrawline(Noteid,rectNoteLine2b)
boxdrawline(Noteid,rectNoteLine3b)
BoxPen(Noteid,GRAY,notepenwidthb)
boxdrawline(Noteid,rectNoteLine1b)
boxdrawline(Noteid,rectNoteLine4b)

BoxDataTag(Noteid,"NOTE")
;BoxDataClear(Noteid,"NOTE")
BoxDrawText(Noteid,rectNoteText,x2,1,4)


Explorer=0
ExploreCD=0
if ( (WinMetrics(-4) >= 4) && (WinVersion(@MAJOR)>=4))   ; Win95  or NT 4.0
    if FileExist("C:\wbsetup.app")
       Explorer=1
    else
       Explorer=AppExist("Explorer")
    endif
    a=DirGet()
    a=strsub(a,1,2)
    if ItemLocate(strupper(a),strupper(DiskScan(8)),@tab)!=0 then ExploreCD=1 
endif

;Sort out shortcut directories, mostly for XP    XP FIX 20011024


if WinVersion(4)==5   ; 95/98/ME
    SHMasterPrograms=ShortCutDir("Programs",0,1)
    SHMasterStartup=ShortCutDir("Startup",0,1)
else   ;NT/2000/XP
    ErrorMode(@off)
    flag=RegSetValue(@REGMACHINE,"Software\Wilson WindowWare[admintest]","test data")
    ErrorMode(@cancel)
    if flag==0
       iniitem="a:AdminX1"
       gosub GetIniItem
       iniitem="b:AdminX2"
       gosub GetIniItem
       Message(a,b)
       exit
    endif

    if WinVersion(@MAJOR) <= 4   ; NT 4.0 3.51
        SHMasterPrograms=ShortCutDir("Programs",0,1)
        SHMasterStartup=ShortCutDir("Startup",0,1)
    else                         ; ver 5.0 +++ 2000/XP/+++
        SHMasterPrograms=ShortCutDir("Common Programs",1,1)
        if SHMasterPrograms== ""
           SHMasterPrograms=ShortCutDir("Programs",0,1)
        endif
        
        SHMasterStartup=ShortCutDir("Common Startup",1,1)
        if SHMasterStartup==""
           SHMasterStartup=ShortCutDir("Startup",0,1)
        endif
    endif   
endif




PManCount=0


for i=1 to 100
   iniitem="a:winclose%i%"
   gosub GetSetupItem
   if a=="XXX" then break
   if WinExist(a)
       WinClose(a)
       Display(4,Title,"Auto-closing %a% for setup")
   endif
next

;If run with no parameters, then the user
;is starting this up for the first time
iniitem="exam:exam"
gosub GetIniItem
BoxDataClear(Noteid,"NOTE")
BoxTextColor(Noteid,BLUE)
BoxDrawText(Noteid,rectnotetext,exam,1,4)

if param0!=0
   if !IsInt(param1)
       param0=0
   else
      if param1<25
         If param0!=3
            Message("Incorrect number of params",param0)
            exit
         endif
         SrcPath=param2
         DestDir=param3
         SetState=param1
      endif
      if param1>89    ; Uninstalling ???
         SetState=param1
         logfile=param2
      endif
   endif
endif

;debug(1)
if param0==0
     a=IniReadPvt("Setup Data","Status",0,infname)
     if iconsonly==1 then a=0  ;LEP ADDED THIS IN
     SetState=95
     if a==0 then SetState=1
     if a==1
         SetState=90
           if UseLongNames
                  logfile=strcat(DirGet(),inireadpvt("Setup Data","loglong","setup.log",infname))
           else
                 logfile=strcat(DirGet(),inireadpvt("Setup Data","logshort","setup.log",infname))
           endif
     else
       SrcPath=FilePath(exename)             ;Get Source path
       if dbg then SrcPath=dbgSrcPath
       DestDir="Unknown"
     endif
endif

OnTheHD=@FALSE
 

While @TRUE
;Pause("SetState=%SetState%","DestDir=%DestDir% SrcPath=%SrcPath%")
switch SetState
case 1
    v=WinVersion(1)
    b=TimeDiffDays(killdate,TimeYmdHms())
    a=@YES
    if   (killversion-v)<=0
       Message("Warning","The current version of windows may be too advanced for the proper operation of this product. System instability may result.")
       a=AskYesno("Warning: Outdated Version","Are you sure you wish to continue the install.")
    endif
	
	if b<0
	    a=AskYesNo("Version is outdated.","Newer versions may be available.  Do you wish to continue the install")
	endif
   if ((killversion-v)<=0 ) || (b<0)
	   Message("Update Information","New versions may be obtained at http://www.windowware.com")
   endif
   if a==@NO
      exit
	endif
     
	
	
	SetState=2
	iniitem="exam:collect"
	Gosub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)
	; fall thru break
case 2	 ;TOPOFSETUP
	bigbocksvar="tosa"
	gosub bbfill
	
	textvar="tosb"
	gosub textfill
	
DlgFormat=`WWWDLGED,6.1`
DlgCaption=Title
DlgX=9999
DlgY=9999
DlgWidth=280
DlgHeight=160
DlgNumControls=6
if ExploreCD==1 then DlgNumControls=8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DlgProcedure=`DEFAULT`
DlgFont=`DEFAULT`
DlgTextColor=`DEFAULT`
DlgBackground=`"setupg.bmp",128|128|128`
Dlg001=`188,119,25,21,PICTUREBUTTON,DEFAULT,"%NextButton%",1,1,DEFAULT,DEFAULT,DEFAULT,"setupn.bmp"`
Dlg002=`226,119,27,21,PICTUREBUTTON,DEFAULT,"%CancelButton%",0,2,DEFAULT,DEFAULT,DEFAULT,"setupc.bmp"`
Dlg003=`9,10,86,80,VARYTEXT,textall,"textall",DEFAULT,3,DEFAULT,"Arial|6963|170|34","255|255|255",DEFAULT`
Dlg004=`103,10,155,85,VARYTEXT,bigbocks,"bigbocks",DEFAULT,4,DEFAULT,"Arial|8192|40|34","255|255|255",DEFAULT`
Dlg005=`190,143,33,11,VARYTEXT,NextButtonX,"Next",DEFAULT,5,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg006=`228,143,43,11,VARYTEXT,CancelButtonX,"Cancel",DEFAULT,6,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg007=`20,98,49,42,PICTUREBUTTON,DEFAULT,"%ExploreButton%",2,7,DEFAULT,DEFAULT,DEFAULT,"setupe.bmp"`
Dlg008=`23,143,43,11,VARYTEXT,ExploreButtonX,"Explore CD",DEFAULT,8,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
ButtonPushed=Dialog("Dlg")

	if IsKeyDown(@SHIFT & @CTRL) then Debug(1)	   ; is shift and ctrl down, turn debug on
    if ButtonPushed==2
       run("explorer.exe","/e")
       exit
    endif

	SetState=3
	; fall thru break
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Now figure out where we stick this beastie
case 3 ;WHERETOGO
	iniitem="exam:deter"
	GoSub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)
	x1=IniReadPvt("Setup Data","dir0","Unknown",infname)
	
	;Figure out where to stash files
	ProgFiles=strcat("C:\",x1)
	ErrorMode(@OFF)
	if win32
	   rkey=RegOpenKey(REGXROOT,"SOFTWARE\%regsection%\%regname%\CurrentVersion")
	else
	   rkey=RegOpenKey(REGXROOT,"SOFTWARE\WilsonWindowWare\%regname%\CurrentVersion")
	endif
	if rkey!=0
	   x2=RegQueryStr(rkey,"")
	   RegCloseKey(rkey)
	   if x2!=0 then ProgFiles=x2
	else
	   if Win32
	      rkey=RegOpenKey(REGXROOT,"SOFTWARE\Microsoft\Windows\CurrentVersion")
	      if rkey!=0
		 x2=RegQueryStr(rkey,"[ProgramFilesDir]")
		 RegCloseKey(rkey)
		 if x2!=0 then ProgFiles=strcat(x2,"\",x1)
	      endif
	   endif
	endif
	ErrorMode(@CANCEL)
;LEP ADDED IN HERE	
	if iconsonly == 1   
	   netdir=WinExeName("")   ; then stuff in the directory above here	 
	   WBpath=filepath(netdir)
	   length=strlen(wbpath)
	   newdir=strsub(wbpath, 1, length -1)
	   wbrootdir=filepath(newdir)
	 endif
 
	bigbocksvar="wtga"
	if iconsonly==1 then bigbocksvar="iwtga"
	gosub bbfill
	
	textvar="wtgb"
	if iconsonly==1 then textvar="iwtgb"
	gosub textfill
   exp1=strcat(text3,@crlf,text4)
	text3=""
	text4=""
	RadioCity=1
	if iconsonly==1
	   x1=wbrootdir
	else
	   x1=Progfiles
	endif	
	x2="Other"


DlgFormat=`WWWDLGED,6.1`
DlgCaption=Title
DlgX=9999
DlgY=9999
DlgWidth=280
DlgHeight=160
DlgNumControls=11
DlgProcedure=`DEFAULT`
DlgFont=`DEFAULT`
DlgTextColor=`DEFAULT`
DlgBackground=`"setupg.bmp",128|128|128`
Dlg001=`6,10,86,101,VARYTEXT,textall,"textall",DEFAULT,1,DEFAULT,"Arial|6963|170|34","255|255|255",DEFAULT`
Dlg002=`100,6,155,46,VARYTEXT,bigbocks,"bigbocks",DEFAULT,2,DEFAULT,"Arial|8192|40|34","255|255|255",DEFAULT`
Dlg003=`100,58,155,26,VARYTEXT,exp1,"exp1",DEFAULT,3,DEFAULT,"Arial|8192|40|34","255|255|255",DEFAULT`
Dlg004=`116,86,129,15,RADIOBUTTON,RadioCity,"%x1%",1,4,DEFAULT,"Arial|8192|70|34","255|255|255",DEFAULT`
Dlg005=`116,100,123,16,RADIOBUTTON,RadioCity,"%x2%",2,5,DEFAULT,"Arial|8192|70|34","255|255|255",DEFAULT`
Dlg006=`28,119,24,21,PICTUREBUTTON,DEFAULT,"%BackButton%",2,6,DEFAULT,DEFAULT,DEFAULT,"setupb.bmp"`
Dlg007=`188,119,25,21,PICTUREBUTTON,DEFAULT,"%NextButton%",1,7,DEFAULT,DEFAULT,DEFAULT,"setupn.bmp"`
Dlg008=`226,119,27,21,PICTUREBUTTON,DEFAULT,"%CancelButton%",0,8,DEFAULT,DEFAULT,DEFAULT,"setupc.bmp"`
Dlg009=`190,143,33,11,VARYTEXT,NextButtonX,"Next",DEFAULT,9,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg010=`228,143,43,11,VARYTEXT,CancelButtonX,"Cancel",DEFAULT,10,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg011=`30,143,41,11,VARYTEXT,BackButtonX,"Back",DEFAULT,11,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
ButtonPushed=Dialog("Dlg")

	if IsKeyDown(@SHIFT & @CTRL) then Debug(1)	   ; is shift and ctrl down, turn debug on
	if buttonpushed==2 
		SetState=2
		break ;SPECIFYSTUFF
	endif
	
	; if the user is not wild about the directory...
	
	if RadioCity==1	  ; Accept Default
	    TryDest=x1
	    DestDir=x1
	else		  ; Allow user to choose
	    TryDest=""
	    DestDir=x1
	   
	endif
	
	if iconsonly==1	      ; NOT LEP
	   wbrootdir=Destdir
	endif
	
	;Here we start remembering what we are up to.  We start off a loglog varaible
	loglog=strcat("NOTE ******************************",@CRLF,"NEWINSTALL ",TimeYmdHms()," ",TimeDate(),@CRLF)
   loglog=strcat(loglog,"NOTE Version=",Version(),"   VersionDLL=",VersionDll(),@CRLF)
		     ;VerifyDestDir will add to it.  We will later write it out to our
		     ;target directory.
	
	vddstatus=0		 ;0=Faileded 1=Dir was already there  2=we made dir
	gosub VerifyDestDir
	if vddstatus==0 
		SetState=3  
		break  ; WHERETOGO
	endif
	
	if strlower(DestDir)==strlower(SrcPath)
		Message("Sorry","Destination directory cannot be the same as the source directory")
		SetState=3
		break
	endif
	
	a=IniReadPvt("Setup Data","dirsystem","Unknown",infname)
	if strlower(a)=="none" then dirsystem=DestDir
			       else dirsystem=strcat(DestDir,a,"\")
	;Save system dir (the one we hide)
      
	if !DirExist(dirsystem)
	     if iconsonly==0	 ; LEP ADDED THIS HERE
		 DirMake(dirsystem)
		 loglog=strcat(loglog,@CRLF,`DIR CREATE "%dirsystem%" `)
	     endif   ; LEP ADDED THIS HERE
	else
	    loglog=strcat(loglog,@CRLF,`DIR EXISTS "%dirsystem%"`)
	endif
	gosub dolog
	;save dirsystem for uninstall info
	loglog=strcat(loglog,@CRLF,`DIRSYSTEM "%dirsystem%"`)
	gosub dolog

	;Clear out old *.gid files if any
	ErrorMode(@off)
	FileAttrSet(strcat(dirsystem,"*.gid"),"rash")
	FileDelete(strcat(dirsystem,"*.gid"))
	ErrorMode(@CANCEL)
	loglog=strcat(`FILE FAKE "`,dirsystem,`*.BAK"`,@crlf)
	loglog=strcat(loglog,`FILE FAKE "`,dirsystem,`*.GID"`)
	gosub dolog

    ;delete setup.dll if it exists.  It is really a WBC file.
    ;if one gets installed later, we'll call it.

	ErrorMode(@off)
	FileAttrSet(strcat(dirsystem,"setup.dll"),"rash")
	FileDelete(strcat(dirsystem,"setup.dll"))
	FileAttrSet(strcat(DestDir,"setup.dll"),"rash")
	FileDelete(strcat(DestDir,"setup.dll"))
	ErrorMode(@CANCEL)

	SetState=4
	;fall thru break
	
	; now that we have a dest\system dir, if we are on a floppy, boop over to HD
	
case 4
     if OnTheHD==@TRUE
	     ;fake parameters
	param0=3
	param1=5  
	param2=Srcpath
	param3=DestDir
	SetState=5
	break
     endif

     ; Put setup files in Install directory for later uninstall
     ;Hmm if we are on a floppy, heave us over to the hard drive
	iniitem="exam:fromflop"
	GoSub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)
	exe2=strupper(strsub(exename,1,2))    ;Are we on a floppy???
	exe=IniReadPvt("Setup Files","exe%wincode%",0,infname)
	dll=IniReadPvt("Setup Files","dll%wincode%",0,infname)
	
	flopexe=strcat(srcpath,exe)
	flopdll=strcat(srcpath,dll)
	flopinf=infname
   flopbmp=strcat(srcpath,"*.bmp")
	
	;hdexe=strcat(dirsystem,FileRoot(flopexe),".",FileExtension(flopexe))
	hdexe=strcat(dirsystem,"uninstal.exe")
	hddll=strcat(dirsystem,dll)
	hdinf=strcat(dirsystem,"setup.inf")
   hdbmp=strcat(dirsystem,"*.bmp")
   dllcopyOKflag=1
if iconsonly==0	  ;LEP added this	

   ;boop the bmp's over
   if FileItemize(hdbmp) != "" then FileAttrSet(hdbmp,"rAsh")
   FileCopy(flopbmp,hdbmp,0)
   FileAttrSet(hdbmp,"rAsh")
   loglog=strcat(`FILE FAKE "`,hdbmp,`"`)
   gosub DOLOG

	if FileExist(hdexe) then FileAttrSet(hdexe,"rAsh")
	FileCopy(flopexe,hdexe,0)
    FileAttrSet(hdexe,"rAsh")
	loglog=`FILE SETUP "%hdexe%"`
	gosub DOLOG

	ErrorMode(@OFF)
   LastError()
	if FileExist(hddll) then FileAttrSet(hddll,"rAsh")
	dllcopyOKflag=FileCopy(flopdll,hddll,0)
   loglog=strcat("NOTE ********WBD DLL FileCopy A Status =",dllcopyOKflag,"  LastError=",LastError())
   loglog=strcat(loglog,@crlf,"NOTE ********WBD DLL - FlopDll=",flopdll,"  HDDLL=",hddll)
   gosub DOLOG
   if dllcopyOKflag==0
      if dllcopydebug==1
         Pause("DLL copy A failed",LastError())
      endif
   endif
   FileAttrSet(hddll,"rAsh")
	ErrorMode(@CANCEL)
	loglog=`FILE SETUP "%hddll%"`
	gosub DOLOG
	if FileExist(hdinf) then FileAttrSet(hdinf,"rAsh")
	FileCopy(flopinf,hdinf,0)
    FileAttrSet(hdinf,"rAsh")
	loglog=`FILE SETUP "%hdinf%"`
	gosub DOLOG
	IniWritePvt("Setup Data","Status",1,hdinf)
endif	       ; LEP added this	       
	;now that we got this far, tell system that we can uninstall
	if Win32
		regwho="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%regname%"
		rkey=RegCreateKey(REGXROOT,regwho)
		RegSetValue(rkey,"[DisplayName]",regname)
		x1=strcat(`"`,hdexe,`" 90 "`,logfile,`"`)
		RegSetValue(rkey,"[UninstallString]",x1)
		RegCloseKey(rkey)
		loglog=strcat(`REG KEY REGXROOT "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" "%regname%"`,@CRLF)
		loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [DisplayName] "%regname%"`,@CRLF)
		loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [UninstallString] `,strcat(`"`,hdexe,`" 90 "`,logfile,`"`))
		gosub dolog
	endif
     ; to force Floppy or HD install without checking install
     ;set dskcode in [Setup Data] section of setup.inf file
     ; 0=hd  1=floppy
     ;dskcode=inireadpvt("Setup Data","dskcode","XXX",infname)
     if !IsDefined(dskcode) then  dskcode=ItemLocate(exe2,DiskScan(1),@tab)
     if (dskcode!=0)   ;Move code to HD and run from there
	;BoxText("Transferring to Hard drive copy")
	iniitem="x1:Title"
	gosub GetIniItem
	iniitem="x2:Transfer"
	gosub GetIniItem
	;BoxOpen(x1,x2)
	Display(4,x1,x2)

   ;debug(@ON) ; xxxyyyzzz
	
	;and run setup program from HD, passing parameters
	   Exclusive(@OFF)
	   if Win32
	      RunShell(hdexe,strcat(`5 "`,SrcPath,`" "`,DestDir,`"`),dirsystem,@NORMAL,@NOWAIT)
	      TimeDelay(8)
	      exit
	   else
	      DirChange(dirsystem)
	      a=strcat(srcpath,"setup.exe")
	      b=strcat(hdexe,` 5 "`,SrcPath,`" "`,DestDir,`"`)
	      ;Message(a,b)
	      Run(a,b )
	      exit
	   endif
	exit
     else     ; not on a floppy
	;fake parameters
	param0=3
	param1=5  
	param2=Srcpath
	param3=DestDir
     endif
     SetState=5
     ;fall thru break

case 5	  ;SPECIFYSTUFF
	OnTheHD=@TRUE
	a=IniReadPvt("Setup Data","dirsystem","Unknown",infname)
	if strlower(a)=="none" then dirsystem=DestDir
			       else dirsystem=strcat(DestDir,a,"\")
	iniitem="exam:detcomp"
	GoSub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)

	textvar="ssa"
	gosub textfill
	
	;is dest a named drive or net path
	if strsub(DestDir,1,2)=="\\"  
	   ;net path
	   x=StrIndex(DestDir,"\",3,@FWDSCAN)
	   x=strsub(DestDir,1,x)
	else
	   if strsub(DestDir,2,1)==":"
	      ; drive?
	      x=Strsub(DestDir,1,2)
	   else
	      ;illegal
	      Message("Error",strcat(DestDir,@crlf,"is an illegal path."))
	      SetState=3
	      break
	   endif
	endif
	
	textall=strcat(textall,x)
	DiskHave=DiskFree(x)
	textall=strcat(textall,"    ",int(DiskHave/1024),"KB")
		    
	iniitem="text11:ssa11"
	gosub GetIniItem
	
	ChoiceCount=0
	for i=1 to 8
	   iniitem="x%i%:choice%i%"
	   gosub GetSetupItem
	   if x%i%=="XXX" 
	     check%i%=0
	     dasize%i%=0
	     continue
	   endif
	   ChoiceCount=i
	   iniitem="check%i%:check%wincode%%i%"
	   gosub GetSetupItem
	   if check%i%=="XXX" then check%i%=0
	   if strlower(check%i%)=="explorer" then check%i%=Explorer
	   if strlower(check%i%)=="network"
	       if strlower(netinfo(0))=="none" then check%i%=0
	       else check%i%=1
	   endif
	   iniitem="dasize%i%:size%i%"
	   gosub GetSetupItem
	   if dasize%i%=="XXX" then dasize%i%=0
	next
	
	DiskReq=0
	for i=1 to 8
	  if check%i%==1 then DiskReq=DiskReq+dasize%i%
	  if iconsonly==1 then dasize%i%=""
	  else dasize%i%=strcat(dasize%i%,"KB")
	next
	textall=strcat(textall,@crlf,@crlf,text11,"    ",DiskReq,"KB")

     
DlgFormat=`WWWDLGED,6.1`
DlgCaption=Title
DlgX=9999
DlgY=9999
DlgWidth=280
DlgHeight=160
DlgNumControls=5 + (Choicecount * 2)
DlgProcedure=`DEFAULT`
DlgFont=`DEFAULT`
DlgTextColor=`DEFAULT`
DlgBackground=`"setupg.bmp",128|128|128`
Dlg001=`188,119,25,21,PICTUREBUTTON,DEFAULT,"%NextButton%",1,1,DEFAULT,DEFAULT,DEFAULT,"setupn.bmp"`
Dlg002=`226,119,27,21,PICTUREBUTTON,DEFAULT,"%CancelButton%",0,2,DEFAULT,DEFAULT,DEFAULT,"setupc.bmp"`
Dlg003=`190,143,33,11,VARYTEXT,NextButtonX,"Next",DEFAULT,3,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg004=`228,143,43,11,VARYTEXT,CancelButtonX,"Cancel",DEFAULT,4,DEFAULT,"Arial|8192|70|34","192|192|192",DEFAULT`
Dlg005=`6,10,86,130,VARYTEXT,textall,"textall",DEFAULT,5,DEFAULT,"Arial|6963|170|34","255|255|255",DEFAULT`
Dlg006=`100,4,137,16,CHECKBOX,Check1,"%x1%",1,6,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg007=`239,7,35,11,VARYTEXT,dasize1,"101K",DEFAULT,7,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg008=`100,18,137,16,CHECKBOX,check2,"%x2%",1,8,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg009=`239,22,35,9,VARYTEXT,dasize2,"102K",DEFAULT,9,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg010=`100,33,137,14,CHECKBOX,check3,"%x3%",1,10,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg011=`239,34,35,11,VARYTEXT,dasize3,"103K",DEFAULT,11,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg012=`100,46,137,15,CHECKBOX,Check4,"%x4%",1,12,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg013=`239,49,35,11,VARYTEXT,dasize4,"104K",DEFAULT,13,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg014=`100,60,137,16,CHECKBOX,Check5,"%x5%",1,14,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg015=`239,63,35,11,VARYTEXT,dasize5,"105K",DEFAULT,15,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg016=`100,74,137,16,CHECKBOX,check6,"%x6%",1,16,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg017=`239,76,35,12,VARYTEXT,dasize6,"106K",DEFAULT,17,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg018=`100,89,137,14,CHECKBOX,check7,"%x7%",1,18,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg019=`239,90,35,10,VARYTEXT,dasize7,"107K",DEFAULT,19,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg020=`100,102,137,15,CHECKBOX,Check8,"%x8%",1,20,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
Dlg021=`239,105,35,11,VARYTEXT,dasize8,"108K",DEFAULT,21,DEFAULT,"Arial|6963|70|34","255|255|255",DEFAULT`
ButtonPushed=Dialog("Dlg")

	if IsKeyDown(@SHIFT & @CTRL) then Debug(1)	   ; is shift and ctrl down, turn debug on
	if buttonpushed==2 
		SetState=3
		break  ; topofsetup
	endif
   
	SetState=6
	;fall thru break
     
case 6	      
	iniitem="exam:getready"
	GoSub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)
	;Now save options user selected
	loglog="NOTE OptCount=%ChoiceCount% %@CRLF%"
	FilesToCopy=0
	FilesCopied=0
	IconsOK=1
	for i=1 to ChoiceCount 
	   iniitem="x1:choice%i%"
	   gosub GetSetupItem
	   b=check%i%
	   loglog=strcat(loglog,"NOTE OPT%i%=",b,"   ",x1,@CRLF)
	   if b!=0
	      iniitem="a:count%i%"
	      gosub GetSetupItem
	      if IsNumber(a) then FilesToCopy=FilesToCopy+a
	      ;Message("Choice=%i% Fc=%a%","Total Files=%FilesToCopy%")
	   endif
	next
	gosub dolog
	
	;save destination directory
	loglog=strcat(loglog,@CRLF,"NOTE Destination Dir ",`"`,DestDir,`"`)
	gosub dolog
	
	;Remember where we are.	 Put us in the registry
	if Win32
		regwho="SOFTWARE\%regsection%\%regname%\CurrentVersion"
		rkey=RegCreateKey(REGXROOT,regwho)
		RegSetValue(rkey,"",DestDir)
		RegCloseKey(rkey)
		loglog=strcat(`REG WWW REGXROOT "SOFTWARE" "%regsection%"`,@CRLF)
		loglog=strcat(loglog,`REG KEY REGXROOT "SOFTWARE\%regsection%" "%regname%"`,@CRLF)
		loglog=strcat(loglog,`REG KEY REGXROOT "SOFTWARE\%regsection%\%regname%" "CurrentVersion"`,@CRLF)
		loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [] `,`"`,DestDir,`"`)
		gosub dolog
	else
		regwho="SOFTWARE\WilsonWindowWare\%regname%\CurrentVersion"
		rkey=RegCreateKey(REGXROOT,regwho)
		RegSetValue(rkey,"",DestDir)
		RegCloseKey(rkey)
		loglog=strcat(`REG WWW REGXROOT "SOFTWARE" "WilsonWindowWare"`,@CRLF)
		loglog=strcat(loglog,`REG KEY REGXROOT "SOFTWARE\WilsonWindowWare" "%regname%"`,@CRLF)
		loglog=strcat(loglog,`REG KEY REGXROOT "SOFTWARE\WilsonWindowWare\%regname%" "CurrentVersion"`,@CRLF)
		loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [] `,`"`,DestDir,`"`)
		gosub dolog
	endif
	
	x=0
	while 1
		x=x+1
		;OK we are pretty much ready.  First we create a few more directories
		dir%x%=IniReadPvt("Setup Data","dir%x%","Unknown",infname)
		if dir%x%=="Unknown" then break	  ; all doned
		dir%x%=strcat(DestDir,dir%x%,"\")
		x1=dir%x%
	
		if !DirExist(x1)
		       if iconsonly==0	   ; LEP ADDED THIS HERE
			  DirMake(x1)
			  loglog=strcat(loglog,`DIR CREATE "%x1%" `)
		       endif		   ; LEP ADDED THIS HERE
		else
		    loglog=strcat(loglog,`DIR EXISTS "%x1%"`)
		endif
		gosub dolog
		;Clear out old *.gid files if any
		ErrorMode(@off)
		FileAttrSet(strcat(dir%x%,"*.gid"),"rash")
		FileDelete(strcat(dir%x%,"*.gid"))
		ErrorMode(@CANCEL)
		loglog=strcat(`FILE FAKE "`,dir%x%,`*.BAK"`,@crlf)
		loglog=strcat(loglog,`FILE FAKE "`,dir%x%,`*.GID"`)
		gosub dolog
	endwhile
	
	;OK we are ready,  Here we go
	RestartRequired=@FALSE
	RebootRequired=@FALSE
	NewFileNameUsed=@FALSE
	DirLinkFixed=@FALSE
	iniitem="exam:doingit"
	GoSub GetIniItem
	BoxDataClear(NoteId,"NOTE")
	BoxTextColor(Noteid,BLUE)
	BoxDrawText(Noteid,rectNoteText,exam,1,4)
	iniitem="x1:doita4"
	gosub GetIniItem
	iniitem="x2:doita5"
	gosub GetIniItem
	;Draw thermoneter outline
	BoxNew(Thermid,rectTherm,2)
	BoxUpdates(Thermid,0)
	BoxCaption(Thermid,x1)
	BoxColor(Thermid,LTGRAY,0)
	BoxDrawRect(Thermid,"",2)
	; Draw updating thermometer here
	; there are 3 virtual pixels per percent
	; we have to draw 3 boxes and some text...
	BoxDataTag(Thermid,"FRED")	  
	   iniitem="mfsort:MainFolderSort"
	   gosub GetSetupItem
	   if strlen(mfsort)==1
	       mfsort=strcat(mfsort,") ")
	       mfkill="?) "
	   else 
	       mfsort=""
	       mfkill=""
	   endif
	   
	iniitem="maxdisks:maxdisks"
	gosub GetSetupItem

	for dsknum=1 to maxdisks
	
	for choicenumber=1 to ChoiceCount
	   ThisCheck=Check%ChoiceNumber%
	   if ThisCheck==0 then continue
	   
	   iniitem="ThisChoice:Choice%ChoiceNumber%"
	   gosub GetSetupItem
	   iniitem="ThisSize:Size%ChoiceNumber%"
	   gosub GetSetupItem
	   
	   ; Maybe check for enuf disk again here
;debug(1) ;;LEP ADDED THIS HERE		   
	   ThisFileNumber=0
	   While 1	;for each file in choice category
	      ThisFileNumber=ThisFileNumber+1
	      ThisFileInfo=IniReadPvt("Setup Data","f%choicenumber%x%ThisFileNumber%","XXX",infname)
	      if ThisFileInfo=="XXX" then break
	      TFDisk =strlower(strtrim(ItemExtract(1,ThisFileInfo,",")))
	      if stricmp("disk%dsknum%",TFDisk)!=0 then continue
	      BoxCaption(Thermid,ThisChoice)

	      TFCodes=strlower(strtrim(ItemExtract(2,ThisFileInfo,",")))
	      TFImage=strtrim(ItemExtract(3,ThisFileInfo,","))
	      TFShort=strtrim(ItemExtract(4,ThisFileInfo,","))
	      TFLong=strtrim(ItemExtract(5,ThisFileInfo,","))
	      DestSubPath=FilePath(TFLong)
	      TFShort=strcat( FileRoot(TFShort),".",FileExtension(TFShort))
	      TFLong=strcat( FileRoot(TFLong),".",FileExtension(TFLong))
	      UseLong =TFLong
	      UseShort = TFShort
	      if UseLongNames
		  TFUseFN =TFLong
	      else
		  TFUseFN = TFShort
	      endif
	      
	      FilesCopied=FilesCopied+1		  
	      
	      iniitem="x1:doita6"
	      gosub GetIniItem
	      x1=strcat(x1,TFUseFN)
   BoxDataClear(Thermid,"FRED")
   BoxUpdates(Thermid,0)
   ;BoxCaption(1,ChoiceNumber)
   BoxColor(Thermid,GREEN,0)
   xxx= 100+((800*FilesCopied)/FilesToCopy)
   per=(100.0*FilesCopied)/FilesToCopy
   per=Int(per)
;rectThermDone=`"100,550,%%xxx%%,800"`
;rectThermLeft=`"%%xxx%%,550,900,800"`
   BoxDrawRect(Thermid,"104,554,%xxx%,796",2)
   BoxColor(Thermid,GRAY,0)
   BoxDrawRect(Thermid,"%xxx%,554,899,796",2)
   BoxPen(Thermid,BLACK,ThermPenWidth)
   boxdrawline(Thermid,rectThermLine1)
   boxdrawline(Thermid,rectThermLine2)
   boxdrawline(Thermid,rectThermLine3)
   boxdrawline(Thermid,rectThermLine4)
   
   ;BoxTextRect(Thermid,rectThermPercent)
   if per<50 then BoxTextColor(Thermid,WHITE)
   BoxDrawText(Thermid,rectThermPercent,"%per%%%",0,0)
   BoxTextColor(Thermid,BLACK)
   BoxColor(Thermid,LTGRAY,0)
   ;BoxTextRect(Thermid,rectThermText1)
   if iconsonly==1 
      BoxDrawText(Thermid,rectThermText1,"Making Shortcut number %FilesCopied%",1,0)
   else
      BoxDrawText(Thermid,rectThermText1,"Copying file number %FilesCopied%",1,0)
   endif
   ;BoxTextRect(Thermid,rectThermText2)
   BoxDrawText(Thermid,rectThermText2,strcat("File: ",TFUseFN),1,0)
   ;BoxTextRect(Thermid,rectThermText3)
   BoxDrawText(Thermid,rectThermText3,strcat("To: ",DestDir,DestSubPath),1,0)
   BoxUpdates(Thermid,2)
   if dbgnocopy
      ;TimeDelay(1)
      continue
   endif
     ;;;;;;;;;;NORMAL;;;;;;;;;;;NORMAL;;;;;;;;;;;;;NORMAL;;;;;;;
     ;;;;;;;;;;NOREPLACE;;;;;;;;NOREPLACE;;;;;;;;;;NOREPLACE;;;;;
	      x=ItemLocate("normal",TFCodes,"|")
	      NoReplace=ItemLocate("noreplace",TFCodes,"|")
	      if NoReplace then NoReplace=1
	      InstDestDir=strcat(DestDir,DestSubPath)
	      wildll=ItemLocate("wildll%wincode%",TFCodes,"|")

         if IsDefined(dllcopyOKflag)==@FALSE then dllcopyOKFlag=0

	      if (wildll!=0)
             if dllcopyOKflag==1   ; copy worked
                  x=0    ; Don't need to install our setup dll
             else
                if dllcopydebug==1
                  Pause("Debug Note","DLL copy being forced")
                endif
             endif
         endif


              DoSystem=ItemLocate("system",TFCodes,"|")+ItemLocate("ctl95",TFCodes,"|")+ItemLocate("ctlnt",TFCodes,"|")
              If DoSystem then DoSystem=1
              if DoSystem
                  InstDestDir=DirWindows(1)
                  a=strsub(InstDestDir,strlen(InstDestDir),1)
                  if a!="\" then InstDestDir=strcat(InstDestDir,"\")
              endif
              
              If WinMetrics(-4)!=5 && ItemLocate("ctl95",TFCodes,"|")!=0
                 ;ohhhh Not 95 system  and ctl3d95    skip this one
                 NoReplace=0
                 x=0
              else
                 If WinMetrics(-4)!=4 && ItemLocate("ctlnt",TFCodes,"|")!=0
                     ; ohhhh  Not NT System and NT dll.  Skip this one
                     NoReplace=0
                     x=0
                 else
                    fd=strcat(InstDestDir,TFUseFN)
                    UseName=fd
                    if ((DoSystem!=0) && (NoReplace!=0))    ; protect system directory
                       if FileExist(fd)
                          NoReplace=0    ;if file exists do not change or alter
                          x=0            ;system directory in any way.  Just hope it works
                       endif
                    endif
                 endif
              endif

              if ItemLocate("dummy",TFCodes,"|")!=0
                  fd=strcat(InstDestDir,TFUseFN)
                  UseName=fd
                  if FileExist(fd)
                     NoReplace=0
                     x=0
                  endif
              endif
               
              if iconsonly==1   ;LEP added this here
                noreplace=0
                x=0
              endif
              
              if NoReplace!=0
                 if FileExist(fd)
                    fcomp1=FileTimeCode(strcat(SrcPath,TFImage))
                    fcomp2=FileTimeCode(fd)
                    if fcomp1==fcomp2   ; files times are identical
                        NoReplace=0
                        x=0          ; basically skip install
                    else
                        UseShort=strcat(FileRoot(TFShort),".","new")
                        UseLong= strcat("New ",FileRoot(fd),".",FileExtension(fd))
                        if UseLongNames
                            UseName=strcat(FilePath(fd),UseLong)
                        else
                            UseName=strcat(FilePath(fd),UseShort)
                        endif 
                        NewFileNameUsed=@TRUE
                    endif
                 endif
              endif
              
              if iconsonly==1   ;LEP added this here
                noreplace=0
                x=0
              endif
              
              if ((x!=0) || (NoReplace!=0))    ; Do normal and noreplace processing"
                 
                 x=FileLocate(strcat(SrcPath,TFImage))
                 while x==""
                    iniitem="x2:%TFDisk%"
                    gosub GetSetupItem
                    iniitem="x3:doita1"
                    gosub GetIniItem
                    iniitem="x4:doita2"
                    gosub GetIniItem
                    iniitem="x5:doita3"
                    gosub GetIniItem
                    SrcPathx=AskLine(x3,strcat(x4,@crlf,x2,@crlf,x5,TFImage),SrcPath)
                    x=FileLocate(strcat(Srcpathx,TFImage))
                    if x!="" then SrcPath=SrcPathx
                 endwhile
                 
                 ;See if we have access to the target
                 Access=@TRUE
                 if FileExist(UseName)
                    ErrorMode(@OFF)
                    LastError()
                    hand=FileOpen(UseName,"WRITE")
                    err=LastError()
                    ErrorMode(@CANCEL)
                    if err
                        Access=@FALSE
                    else
                        FileWrite(hand,"File Access Test Data")
                        FileClose(hand)
                    endif
                 endif
                 
                 if Access==@TRUE
                    ;FileCopy( strcat(SrcPath,TFImage), UseName, 0)
                    if WinMetrics(-3)>1       ; Non-Intel
                       nonintel=DirGet()      ; ver.dll buggie ????
                       DirChange("\")
                    endif
;                    ifrslt=InstallFile(strcat(SrcPath,TFImage), TFShort, FilePath(UseName),0,2|DoSystem)
                    ifrslt=InstallFile(strcat(SrcPath,TFImage), UseShort, FilePath(UseName),0,2|DoSystem)
                    if WinMetrics(-3)>1       ; Non-Intel
                       DirChange(nonintel)
                    endif
                    if UseLongNames && !DoSystem
;                        if stricmp(TFlong,TFshort)!=0
                        if stricmp(UseLong,UseShort)!=0
                           ErrorMode(@off)
                           LastError()
                           FileMove( strcat(FilePath(UseName),UseShort),strcat(FilePath(UseName),"WW9876AQ.F7T"),0)
                           FileMove( strcat(FilePath(UseName),"WW9876AQ.F7T"),UseName,0)
                           a=LastError()
                           if a!=0
                              debug(1)
                              Message("FileRename Error",a)
                           endif
                           ErrorMode(@cancel)
                        endif
                    endif
                    loglog=strcat(`FILE CREATE "%UseName%"`,@CRLF,"NOTE IFRESULT ",ifrslt)
                    gosub dolog
                 else    ;Access denied
                    ;debug(1)
                    if !(wildll!=0  && dllcopyOKflag==1)  ; if its our wildll abd it copied, then just forget it
                       tmpname2=strcat( FilePath(UseName),FileRoot(TFShort),".RST")
                       ;FileCopy( strcat(SrcPath,TFImage), tmpname2, 0)
                       ifrslt=InstallFile( strcat(SrcPath,TFImage), strcat( FileRoot(tmpname2),".",FileExtension(tmpname2)), FilePath(tmpname2) , 0 ,2)
                       loglog=strcat(`FILE CREATEDEFERRED "%UseName%"`,@CRLF,"NOTE IFRESULT ",ifrslt)
                       gosub dolog
                       x=WinMetrics(-4)   ; Win95 or NT
                       if x==4    ;Windows NT
                          IntControl(30, tmpname2, UseName, 0, 0) ;FileMoveonReboot                      
                          RebootRequired=@TRUE
                       endif
                       if x==5   ; Windows 95
                          x1=FileNameShort(UseName)   ; Get Short Name
                          x2=FileNameShort(tmpname2) 
                          IniWritePvt("rename",x1,x2,"wininit.ini")
                          RestartRequired=@TRUE
                       endif
                    endif
                 endif
              endif

  ;;;;;;;;;;;;;;;;;;;;;;;;;;ICON;;;;;;;;;;;;;;;;;ICON;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DOICONS  
;debug(1)       
              x=ItemLocate("icon",TFCodes,"|")
              if x!=0    ; Do icon processing"
                 z=StrIndex(TFCodes,"?",1,@FWDSCAN)
                 ;if z==0 then Message("Ooops","Icon code missing %ThisFileInfo%")
                 if z==0   ; no icon codes  fake it, we're not using them anymore
                    iconcode="a"
                    iconsort="a) "
                    iconkill="?) "
                 else      ;aha  some icon code in there.  remember it
                    iconcode=strsub(TFCodes,z+1,1)
                    iconsort=strcat(iconcode,") ")    
                    iconkill="?) "    
                 endif
                 if Explorer && IconsOK  ; If using Win95 type interface, just make files, else use DDE
                    ;Get startmenu dir from registry
                    ;XP Fix 20010511
                    ;rkey=RegOpenKey(@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
                    ;strtdir=RegQueryStr(rkey,"[Programs]")
                    ;RegCloseKey(rkey)
                    ;strtdir=ShortCutDir("Programs")  ; XP Fix 20010511
                    ;if strsub(strtdir,strlen(strtdir),1)!="\" then strtdir=strcat(strtdir,"\")
                    ;XP Fix 20011024
                    strtdir=SHMasterPrograms   ;XP Fix 20011024

                    if DirExist(strtdir)
                       MyDir=IniReadPvt("Setup Data","dirstartmenu","WindowWare",infname)
                       strtdir=strcat(strtdir,MyDir,"\")
;Debug(1) ;LEP ADDED THIS IN TO TEST THIS SECTION.  ARGHHH!!!!
                       ;scname=strcat(strtdir,mfsort,MyDir," Folder.lnk")   ;mhw991005            
                       scname=strcat(strtdir,MyDir," Folder.lnk")           ;mhw991005   
                       if !DirExist(strtdir)
                           ErrorMode(@off)
                           LastError()
                           DirMake(strtdir)
                           err=LastError()
                           ErrorMode(@cancel)
                           if err 
                              loglog='NOTE DIR CREATE "%strtdir%" FAILED'
               			      IconsOK=0
               			      Message("Setup Error","Cannot make start menu items.  Protected????")
               			   else
               			      loglog=`DIR CREATE "%strtdir%"`
               			      ;if FileExist(scname) then FileDelete(scname)
               			      if iconsonly==1	; LEP ADDED THIS
                     				  icontarg=strcat(wbrootdir,DestSubPath)
                     				  ShortcutMake(scname,icontarg,"",icontarg,@NORMAL)  ;LEP ADDED THIS
                     			else
                     				  ShortcutMake(scname,InstDestDir,"",InstDestDir,@NORMAL)
               			      endif
               			      loglog=strcat(loglog,@CRLF,`SHORTCUT CREATE "%scname%" `)
               			      DirLinkFixed=@TRUE
               			   endif
		                else
               			   if DirLinkFixed==@FALSE
               			      loglog=`NOTE DIR EXISTS "%strtdir%" already exists`
               			      ;if FileExist(scname) then FileDelete(scname)
               			      sckillname=strcat(strtdir,mfkill,MyDir," Folder.lnk")
               			      sckillfiles=FileItemize(sckillname)
               			      if sckillfiles!=""
                     				  a=DirGet()
                     				  DirChange(strtdir)
                     				  ErrorMode(@off)
                     				  LastError()
                     				  FileDelete(sckillfiles)
                     				  scerr8=LastError()
                     				  ErrorMode(@cancel)
                     				  DirChange(a)
                     				  if scerr8
                     				     loglog=strcat(loglog,@crlf,"NOTE SCDELETEA1 FAIL %strtdir% %sckillfiles%")
                     				     gosub dolog
                     				  endif
         			            endif
               			      sckillname=strcat(strtdir,MyDir," Folder.lnk")  ;mhw991005
               			      sckillfiles=FileItemize(sckillname)
               			      if sckillfiles!=""
                     				  a=DirGet()
                     				  DirChange(strtdir)
                     				  ErrorMode(@off)
                     				  LastError()
                     				  FileDelete(sckillfiles)
                     				  scerr8=LastError()
                     				  ErrorMode(@cancel)
                     				  DirChange(a)
                     				  if scerr8
                     				     loglog=strcat(loglog,@crlf,"NOTE SCDELETEA2 FAIL %strtdir% %sckillfiles%")
                     				     gosub dolog
                     				  endif
         			            endif
               			      if iconsonly==1	; LEP ADDED THIS HERE
               			 	      icontarg=strcat(wbrootdir,DestSubPath)
               				      ShortcutMake(scname,icontarg,"",icontarg,@NORMAL) 
         			            else
                  				   ShortcutMake(ScName,InstDestDir,"",InstDestDir,@NORMAL)
            			         endif
               			      loglog=strcat(loglog,@CRLF,`SHORTCUT CREATE "%scname%" `)
               			      DirLinkFixed=@TRUE
               			   endif
		              endif
		       gosub dolog
		    
		       if IconsOK
			  ;ScName=strcat(strtdir,iconsort,FileRoot(fd)," ",FileExtension(fd),".lnk")   ;mhw991005 ; fd from copy operation above
			  ScName=strcat(strtdir,FileRoot(fd)," ",FileExtension(fd),".lnk")   ;mhw991005 ; fd from copy operation above
			  sckillname=strcat(strtdir,iconkill,FileRoot(fd)," ",FileExtension(fd),".lnk")
			  sckillfiles=FileItemize(sckillname)
			  if sckillfiles!=""
			      a=DirGet()
			      DirChange(strtdir)
			      ErrorMode(@off)
			      LastError()
			      FileDelete(sckillfiles)
			      scerr8=LastError()
			      ErrorMode(@cancel)
			      DirChange(a)
			      if scerr8
				      loglog="NOTE SCDELETEB1 FAIL %strtdir% %sckillfiles%"
				      gosub dolog
			      endif
			  endif
			  sckillname=strcat(strtdir,FileRoot(fd)," ",FileExtension(fd),".lnk")  ;mhw991005
			  sckillfiles=FileItemize(sckillname)
			  if sckillfiles!=""
			      a=DirGet()
			      DirChange(strtdir)
			      ErrorMode(@off)
			      LastError()
			      FileDelete(sckillfiles)
			      scerr8=LastError()
			      ErrorMode(@cancel)
			      DirChange(a)
			      if scerr8
				      loglog="NOTE SCDELETEB2 FAIL %strtdir% %sckillfiles%"
				      gosub dolog
			      endif
			  endif
			  sckillname=strcat(strtdir,FileRoot(fd),".",FileExtension(fd),".lnk")  ;mhw991005
			  sckillfiles=FileItemize(sckillname)
			  if sckillfiles!=""
			      a=DirGet()
			      DirChange(strtdir)
			      ErrorMode(@off)
			      LastError()
			      FileDelete(sckillfiles)
			      scerr8=LastError()
			      ErrorMode(@cancel)
			      DirChange(a)
			      if scerr8
				      loglog="NOTE SCDELETEB3 FAIL %strtdir% %sckillfiles%"
				      gosub dolog
			      endif
			  endif

			  if iconsonly==1	  ; LEP ADDED THIS      ;mhw991005 wbc-34i.exe -> wbcompiler.exe
			    if fileexist(strcat(wbpath,"winfo34i.exe"))==1 || fileexist(strcat(wbpath,"winfo34i.exe"))==2
			       icontarg=strcat(wbrootdir,DestSubPath)
			       TFUseFN = TFShort ;LEP ADDED THIS FOR SHORTFILENAME SERVERS W/ LONGFILENAMED LOCALS
			       icontargfile=strcat(icontarg,TFUseFN)
			       ShortcutMake(scname,icontargfile,"",FilePath(icontargfile),@NORMAL)
			    else
			       icontarg=strcat(wbrootdir,DestSubPath)
			       icontargfile=strcat(icontarg,TFUseFN)
			       ShortcutMake(scname,icontargfile,"",FilePath(icontargfile),@NORMAL)
			    endif
			  else	 
			       ShortcutMake(ScName,fd,"",FilePath(fd),@NORMAL)
			  endif
			  loglog=`SHORTCUT CREATE "%scname%" `
			  gosub dolog
		       endif
		    else
		       loglog=strcat(`NOTE "`,strtdir,`" Start Menu Dir Missing`)
		       gosub dolog
		    endif
		 else	;else no explorer.  Try via DDE
			;Save DDE info for laters
			if IconsOK
			    PManCount=PManCount+1
			    PMD%iconcode%=fd
			endif
			
		 endif	 ; end of 95/DDE switch based on AppExist("Explorer")
	      endif	 ; end of icon add stuff
  ;;;;;;;;;;;APPPATH;;;;;;;;;;;;;;APPPATH;;;;;;;;;;;;APPPATH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DO APPPATH		   
	      x=ItemLocate("apppath",TFCodes,"|")
	      if x!=0	 ; Do apppath processing"
                 if Win32                
                    x=strcat(FileRoot(TFUseFN),".",FileExtension(TFUseFN))
                    regwho="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%x%"
                    rkey=RegCreateKey(REGXROOT,regwho)
                    RegSetValue(rkey,"",fd)
                    cleanapppath=DestDir 
                    if strindexnc(strcat(cleanapppath,";"),strcat(InstDestDir,";"),0,@fwdscan)==0
                       cleanapppath=strcat(cleanapppath,";",InstDestDir)
                    endif
                    if strindexnc(strcat(cleanapppath,";"),strcat(dirsystem,";"),0,@fwdscan)==0
                       cleanapppath=strcat(cleanapppath,";",dirsystem)
                    endif
                    RegSetValue(rkey,"[Path]",cleanapppath)
                    RegCloseKey(rkey)
                    loglog=strcat(`REG KEY REGXROOT "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" "%x%"`,@crlf)                 
                    loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [] `,`"`,InstDestDir,`"`,@CRLF)
                    loglog=strcat(loglog,`REG ITEM REGXROOT "%regwho%"  [Path] `,`"`,cleanapppath,`"`)
                    gosub dolog
                 endif
              endif
  ;;;;;;;;;;;;REGTYPE;;;;;;;;;;;;REGTYPE;;;;;;;;;;;REGTYPE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
              x2=""
              x=itemlocate("regtype",TFCodes,"|")
              if x!=0     ;Do register type processing
                 iniitem="x1:Types %TFShort%"
		 gosub GetSetupItem
		 if x1=="XXX" then Message("Types bad",TFUseFN)
		 x=ItemCount(x1,",")
		 for i=1 to x
		    x2=ItemExtract(i,x1,",")
		    rkey=RegOpenKey(REGXCLASSES,"")
		    ErrorMode(@OFF)
		    RegDeleteKey(rkey,".%x2%")
		    ErrorMode(@CANCEL)
		    if x2=="WBT" && Win32==@TRUE
             RegSetValue(@REGCLASSES,".WBT\ShellNew\[NullFile]","")
             RegSetValue(@REGCLASSES,".WBT\PersistentHandler","{5e941d80-bf96-11cd-b579-08002b30bfeb}")
          endif

		    RegSetValue(rkey, ".%x2%", "%x2%_auto_file")
		    x2xq=x2 ;MORRIE ADDED THIS IN
		    if x2xq=="WBT" then x2xq="WinBatch"
		    RegSetValue(rkey,"%x2%_auto_file","%x2xq% file")
		    if strlower(FileRoot(fd))=="wbat16i"
		       RegSetValue(rkey,"%x2%_auto_file\shell\open\command",strcat(fd,` %%1`))
		    else
		       RegSetValue(rkey,"%x2%_auto_file\shell\open\command",strcat(`"`,fd,`"`,` "%%1"`))
		    endif
		    RegSetValue(rkey,"%x2%_auto_file\shell\print\command","notepad.exe /p %%1")		  
		    RegClosekey(rkey)
		    loglog=strcat(`REG KEY REGXCLASSES "%x2%_auto_file" ".%x2%"`,@crlf)
		    loglog=strcat(loglog,`REG KEY REGXCLASSES "" ".%x2%" `,@CRLF)
		    loglog=strcat(loglog,`REG ITEM REGXCLASSES "" "%x2%_auto_file\shell\open\command" [] `,strcat(`"`,fd,`"`,` "%%1"`))
		    loglog=strcat(loglog,`REG ITEM REGXCLASSES "" "%x2%_auto_file\shell\print\command" [] `,"notepad.exe /p %%1")
		    gosub dolog
		 next
	      endif
  ;;;;;;;;;;;NICREG;;;;;;;;;;;;;;NICREG;;;;;;;;;;;;NICREG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DO APPPATH		
	      x=ItemLocate("nicreg",TFCodes,"|")
	      if x!=0	 ; Do nicreg processing"
                 if Win32
                    clsid="CLSID\{53250000-cca9-11ce-946f-444553540000}"
                    froot=FileRoot(fd)
                    froot2=strcat(froot,".",FileExtension(fd))
                    rkey=RegCreateKey(@REGCLASSES,clsid)
                    RegSetValue(rkey,"",froot)
                    RegCloseKey(rkey)
                    loglog=strcat(`REG KEY @REGCLASSES "CLSID" "{53250000-cca9-11ce-946f-444553540000}"`,froot,`"`)
		    gosub dolog
		    
		    rkey=RegCreateKey(@REGCLASSES,strcat(clsid,"\InProcServer32"))
		    RegSetValue(rkey,"",fd)
		    RegSetValue(rkey,"[ThreadingModel]","Apartment")
		    RegCloseKey(rkey)
		    loglog=strcat(`REG KEY @REGCLASSES "`,clsid,`" "InProcServer32"`)
		    gosub dolog
		    loglog=strcat(`REG ITEM @REGCLASSES "`,clsid,`\InProcServer32" [] "`,fd,`"`)
		    gosub dolog
		    loglog=strcat(`REG ITEM @REGCLASSES "`,clsid,`\InProcServer32" [ThreadingModel] "Apartment"`)
		    gosub dolog
		    
		    rkey=RegCreateKey(@REGCLASSES,strcat("*\shellex\ContextMenuHandlers\",froot))
		    RegSetValue(rkey,"","{53250000-cca9-11ce-946f-444553540000}")
		    RegCloseKey(rkey)
		    loglog=strcat(`REG KEY @REGCLASSES "*\shellex\ContextMenuHandlers" "%froot%"`)
		    gosub dolog
		    loglog=strcat(`REG ITEM @REGCLASSES "*\shellex\ContextMenuHandlers\`,froot,`" [] "`,clsid,`"`)
		    gosub dolog
		 endif
	      endif
	      
;;;;;;;;;;;COREJAVA;;;;;;;;;;;COREJAVA;;;;;;;;;;;COREJAVA
;;;;;;;;;;;COREJAVA;;;;;;;;;;;COREJAVA;;;;;;;;;;;COREJAVA
		 x=ItemLocate("corejava",TFCodes,"|")
		 if x!=0    ; Do corejava processing"
                     iniwritepvt("WinEdit","PROFILTERS","Source Files|*.java|HTML Files|*.html|Text Files|*.txt|All Files|*.*|","winedit.ini")
                     iniwritepvt("WinEdit","TABSIZE","3","winedit.ini")
                     iniwritepvt("WinEdit","PROJECT",strcat(FilePath(UseName),"default.wpj"),"winedit.ini")
                     javaprj=strcat(FileNameShort(strcat(FilePath(UseName),"tee.com"))," javac %%f")
                     iniwritepvt("PROJECT","COMPILE",javaprj,strcat(FilePath(UseName),"default.wpj"))
                     javaprj=strcat(FileNameShort(strcat(FilePath(UseName),"runjava.bat"))," %%n")
                     iniwritepvt("PROJECT","RUN",javaprj,strcat(FilePath(UseName),"default.wpj"))
                 endif
              
;;;;;;;;;;;STARTUP;;;;;;;;;;;;STARTUP;;;;;;;;;;STARTUP;;;;;
;;;;;;;;;;;STARTUP;;;;;;;;;;;;STARTUP;;;;;;;;;;STARTUP;;;;;
              if Explorer
                 x=ItemLocate("startup",TFCodes,"|")
                 if x!=0    ; Do startup processing"
		    ;Get startup dir from registry                XP Fix 20010511
		    ;rkey=RegOpenKey(@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
		    ;x1=RegQueryStr(rkey,"[StartUp]")
		    ;RegCloseKey(rkey)
           ;  x1=ShortCutDir("Startup")   ; XP fix 20010511
		    ;if strsub(x1,strlen(x1),1)!="\" then x1=strcat(x1,"\")
             x1=SHMasterStartup  ;XP FIX 20011024

		    if DirExist(x1)
		       ScName=strcat(x1,FileRoot(fd)," ",FileExtension(fd),".lnk")   ; fd from copy operation above
		       if FileExist(ScName) then FileDelete(ScName)
		       if iconsonly==1	  ; LEP ADDED THIS
			 if fileexist(strcat(wbpath,"winfo34i.exe"))==1 || fileexist(strcat(wbpath,"winfo34i.exe"))==2
			    icontarg=strcat(wbrootdir,DestSubPath)
			    TFUseFN = TFShort  ;LEP ADDED THIS FOR SHORTFILENAMED SERVERS WITH LONGFILENAMED LOCALS
			    icontargfile=strcat(icontarg,TFUseFN)
			    ShortcutMake(scname,icontargfile,"",FilePath(icontargfile),@NORMAL)
			 else
			    icontarg=strcat(wbrootdir,DestSubPath)
			    icontargfile=strcat(icontarg,TFUseFN)
			    ShortcutMake(scname,icontargfile,"",FilePath(icontargfile),@NORMAL)
			 endif
		       else 
			   ShortcutMake(ScName,fd,"",FilePath(fd),@NORMAL)
		       endif
		       loglog=`SHORTCUT CREATE "%scname%" `
		    else
		       loglog=strcat(`NOTE "`,x1,`" StartUp Directory Missing`)
		    endif
		    gosub dolog
		 endif
	      endif
;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE		  
;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE;;;;;;;;;;;;;;;DELETE
	      ;debug(1)
	      x=ItemLocate("delete",TFCodes,"|")
	      if x!=0	; Do delete processing
		  fildellong=strcat(InstDestDir,UseLong)
		  fildelshort=strcat(InstDestDir,UseShort)
		  ErrorMode(@off)
		  fildellongchk=FileDelete(fildellong)
		  fildelshortchk=FileDelete(fildelshort)
		  LastError()
		  ErrorMode(@cancel)
		  loglog=""
		  if fildellongchk then loglog="NOTE FILEDELETE %fildellong% %@crlf%"
		  if fildelshortchk then loglog=strcat(loglog,"NOTE FILEDELETE %fildelshort%")
		  gosub dolog
		  ;debug(1) 
		  if Explorer && IconsOK
		    ;Get startmenu dir from registry
            ;XP Fix 20010511
		    ;rkey=RegOpenKey(@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
		    ;strtdir=RegQueryStr(rkey,"[Programs]")
		    ;RegCloseKey(rkey)
            ;strtdir=ShortCutDir("Programs")  ;XP fix 20010511
		    ;if strsub(strtdir,strlen(strtdir),1)!="\" then strtdir=strcat(strtdir,"\")

            strtdir=SHMasterPrograms ; XP FIX 20011024
		    if DirExist(strtdir)
		       MyDir=IniReadPvt("Setup Data","dirstartmenu","WindowWare",infname)
		       strtdir=strcat(strtdir,MyDir,"\")
		       if DirExist(strtdir)
			      iconkill="?) "
			      sckillname=strcat(strtdir,iconkill,FileRoot(fildellong)," ",FileExtension(fildellong),".lnk")
			      sckillfiles=FileItemize(sckillname)
			      if sckillfiles!=""
			         a=DirGet()
			         DirChange(strtdir)
			         ErrorMode(@off)
			         FileDelete(sckillfiles)
			         LastError()
			         ErrorMode(@cancel)
			         DirChange(a)
			     endif
			     sckillname=strcat(strtdir,iconkill,FileRoot(fildelshort)," ",FileExtension(fildelshort),".lnk")
			     sckillfiles=FileItemize(sckillname)
			     if sckillfiles!=""
			        a=DirGet()
			        DirChange(strtdir)
			        ErrorMode(@off)
			        FileDelete(sckillfiles)
			        LastError()
			        ErrorMode(@cancel)
			        DirChange(a)
			      endif
		       endif
		    endif
		  endif
	      endif
;;;;;;;;;;;;;;END WHILE;;;;;;;;;;;;;END WHILE;;;;;;;;;;
	   end while	; end of file processing for choice category
	
	next	    ; end of choice for loop
	next	    ; end of disk loop
    ; DO PMAN stuff if any
    if PmanCount>0
	;Check to see if Program manager is running.  If not, run it.
	Exclusive(@OFF)
	AX=DDEInitiate("Progman", "Progman")
	IF AX==0    ; Hmmm nobody`s home
	    run("progman.exe","")
	    timedelay(4)
	    AX=DDEInitiate("Progman", "Progman")
	endif
	if AX!=0
	   ErrorMode(@OFF)
	   If AppExist("Progman.exe")  then WinActivate("Program Manager")
	   ErrorMode(@ON)
	   ;show or create the group first.
	   MyDir=IniReadPvt("Setup Data","dirstartmenu","WindowWare",infname)
	   Err=DDEExecute(AX,"[ShowGroup(%MyDir%)]")
	   if Err==0   ; opp no group.	Make it
	      DDEExecute(AX,"[CreateGroup(%MyDir%)]")
	      loglog=`PROGMAN GROUP "%MyDir%"`
	      gosub dolog
	   endif
	   icontry=num2char(char2num("a")-1)
	   scname="*none*"
	   While PMANCount>0
	      icontry=num2char(char2num(icontry)+1)
          if icontry=="{" then break
	      if !IsDefined(PMD%icontry%) then continue
	      fd=PMD%icontry%
	      scname=strcat(FileRoot(fd),".",FileExtension(fd))
	      fdp=FilePath(fd)
	      ; If icon of same name there, kill it
	      DDEExecute(AX,"[DeleteItem(%scname%)]")  ;Ignore error return
	      ;Add the item.	 
	      DDEExecute(AX,`[AddItem("%fd%",%scname%,,,-1,-1,"%fdp%",0)]`)
	      loglog=`PROGMAN ICON "%scname%"`
	      gosub dolog
	      TimeDelay(0.5)
	      PmanCount=PmanCount-1
	   end while
	   ; Kill DDE Conversation
	   DDETerminate(AX)
	endif  ;end of DDEOK doing it stuff
    endif

    SetState=7
    ;fall thru break
    
case 7	      

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iniitem="exam:appstart"
GoSub GetIniItem
BoxDataClear(NoteId,"NOTE")
BoxTextColor(Noteid,BLUE)
BoxDrawText(Noteid,rectNoteText,exam,1,4)
;Starting applications if no reboot or restart required

if (!RebootRequired && !RestartRequired && wincode==32)
   for i=1 to 100
	iniitem="a:restart%i%"
	gosub GetSetupItem
	if a=="XXX" then break
	ErrorMode(@OFF)
	regwho="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\%a%"
	rkey=RegOpenKey(REGXROOT,regwho)
	a=RegQueryStr(rkey,"")
	RegCloseKey(rkey)
	if FileExist(a) then RunShell(a,"",FilePath(a),@NORMAL,@NOWAIT)
	ErrorMode(@CANCEL)
   next
endif
if NewFileNameUsed==@TRUE
	iniitem="x1:newname"
	Gosub GetIniItem
	Message(Title,x1)
endif

;Set Eval control codes
sectionname=IniReadPvt("Setup Data","sectionname","Unknown",infname) ;Get sectionname
series="200101"    ;WinBatch 2001 series    MUST BE A NUMBER !!! 
                   ;WinBatch/WinEdit 98 99 1999 series was 199807   MUST BE A NUMBER
                   ;Using original release date of series


;Call setup.dll file if installed by setup.  It is really a WBC file !!
;It should be *very* careful not to damage any setup variables.
setupdll=strcat(dirsystem,"setup.dll")
if FileExist(setupdll)
   Call(setupdll,"")
else
   setupdll=strcat(DestDir,"setup.dll")
   if FileExist(setupdll)
      Call(setupdll,"")
   endif
endif



SetState=8
Finishlog=@TRUE
;fall thru break

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
case 8
iniitem="exam:instcomp"
GoSub GetIniItem
BoxDataClear(NoteId,"NOTE")
BoxTextColor(Noteid,BLUE)
BoxDrawText(Noteid,rectNoteText,exam,1,4)


while 1 ; do until some kind of exit is resolved.
	iniitem="x1:Title"
	gosub GetIniItem
	if RebootRequired
	      iniitem="x2:Reboot1"
	      gosub GetIniItem
	      iniitem="x3:Reboot2"
	      gosub GetIniItem
	      x2=strcat(x2,@crlf,x3)
	      x=AskYesNo(x1,x2)
          if x==@NO
              iniitem="x3:Reboot3"
              gosub GetIniItem
              loglog="DONE REBOOT REFUSED"
              if FinishLog then gosub dolog
              Message(x1,x3)
              exit                       ; anexit
          endif
	      loglog="DONE REBOOT REQUESTED"
	      if FinishLog then gosub dolog
	      IntControl(67,0,0,0,0)         ; anexit
	else
	   if RestartRequired
	      iniitem="x2:Restart1"
	      gosub GetIniItem
	      iniitem="x3:Restart2"
	      gosub GetIniItem
	      x2=strcat(x2,@crlf,x3)
	      x=AskYesNo(x1,x2)
	      if x==@NO
            iniitem="x3:Restart3"
            gosub GetIniItem
            loglog="DONE RESTART REFUSED"
            if FinishLog then gosub dolog
            Message(x1,x3)
            exit                           ; anexit
	      endif
	      loglog="DONE RESTART REQUESTED"
	      if FinishLog then gosub dolog
	      IntControl(67,0,0,0,0)          ; anexit
	   else
	      gosub GetIniItem
	      iniitem="x2:Comp2"
	      gosub GetIniItem
	      loglog="DONE ALL DONE"
	      if FinishLog then gosub dolog
	      Message(x1,x2)
	      exit                              ; anexit
	   endif
	endif	
endwhile
; Code should never get here  #1
Message("Hmmm 1","Internal Error %param1% %param2%")
exit
break


case 90	  ;Uninstall
	BoxNew(Noteid,rectu,1)
	BoxColor(Noteid,LTGRAY,0)	; Light Gray no gradient
	BoxDrawRect(Noteid,"",2)
	BoxTextFont(Noteid,"Arial",uHeight,0,0)	  ; san-srif, ariel, size 12, nobold, noitalic
	;BoxTextRect(Noteid,rectuText)
	BoxTextColor(Noteid,BLUE)
	BoxDataTag(Noteid,"NOTE")
	;BoxDataClear(Noteid,"NOTE")
	BoxDrawText(Noteid,rectuText,"Considering Uninstall",1,4)
	if dbgnorem
	   TimeDelay(2)
	   SetState=91
	   break
	endif
	
	dirsystem=FilePath(logfile)
	SrcPath=strsub(dirsystem,1,strlen(dirsystem)-1)
	SrcPath=FilePath(SrcPath)
	iniitem="x1:Uninstall"
	gosub getiniitem
	OldCancel=OnCancel
	OnCancel="goto cas90a"
	a=AskYesNo(Title,x1)
	:CAS90A
	OnCancel=OldCancel
	if a==@NO
	   exit
	endif
	BoxTextColor(Noteid,BLUE)
	BoxDataClear(Noteid,"NOTE")
	BoxDrawText(Noteid,rectuText,"Moving uninstall to temp directory",1,4)
	;Step 1 - boop us over to the temp directory ASAP to kill stuff off
	temp=Environment("TEMP")
	if temp=="" then temp=Environment("TMP")
	if temp=="" then temp="C:\"
	if strsub(temp,strlen(temp),1)!="\" then temp=strcat(temp,"\")
	
	exe="uninstal.exe"
	dll=IniReadPvt("Setup Files","dll%wincode%","XXX",infname)
	if exe=="XXX" || dll=="XXX"
	   SheetHappens=@TRUE
	   SetState=91
	   break
	endif
	oldexe=strcat(dirsystem,exe)
	olddll=strcat(dirsystem,dll)
	oldinf=infname
	hdexe=strcat(temp,FileRoot(oldexe),".",FileExtension(oldexe))
	hddll=strcat(temp,dll)
	hdinf=strcat(temp,"setup.inf")
	if FileExist(hdexe) then FileAttrSet(hdexe,"rAsh")
	FileCopy(oldexe,hdexe,0)
    FileAttrSet(hdexe,"rAsh")
	if FileExist(hddll) then FileAttrSet(hddll,"rAsh")
	FileCopy(olddll,hddll,0)
    FileAttrSet(hddll,"rAsh")
	if FileExist(hdinf) then FileAttrSet(hdinf,"rAsh")
	FileCopy(oldinf,hdinf,0)
    FileAttrSet(hdinf,"rAsh")
	
	; mark setup files for death
	    x=WinMetrics(-4)   ; Win95 or NT
	    if x==4    ;Windows NT
	       IntControl(30, hdexe, "", 0, 0) ;KillMoveonReboot		      
	       IntControl(30, hddll, "", 0, 0) ;KillMoveonReboot		      
	       IntControl(30, hdinf, "", 0, 0) ;KillMoveonReboot		      
	    endif
	    if x==5   ; Windows 95/98
	       ;;;;;;;
			wininit= strcat(DirWindows(0),"WININIT.INI")
			if FileExist(wininit)
				fs1=FileSize(wininit)
				srcbuf	= BinaryAlloc(fs1+2000)
				editbuf = BinaryAlloc(fs1+2000)
				BinaryRead( srcbuf, wininit)
				a = BinaryIndex( srcbuf, 0, "rename]", @FWDSCAN)
				if a==0 then a = BinaryIndex( srcbuf, 0, "Rename]", @FWDSCAN)
				if a==0 then a = BinaryIndex( srcbuf, 0, "RENAME]", @FWDSCAN)
				if a==0
				   BinaryPokeStr(srcbuf,fs1,"[rename]%@CRLF%                                                                 %@CRLF%")
				   a=fs
				else
				   a=a-1
				endif
				cuthere = BinaryIndex( srcbuf, a, @CRLF, @FWDSCAN) + 2
				BinaryCopy( editbuf, 0, srcbuf, 0, cuthere)
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hdexe),@CRLF))
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hddll),@CRLF))
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hdinf),@CRLF))
				a = BinaryEodGet(editbuf)
				b = BinaryEodGet(srcbuf)
				BinaryCopy( editbuf, a, srcbuf, cuthere, b-cuthere)
				BinaryWrite( editbuf, wininit)
				BinaryFree(editbuf)
				BinaryFree(srcbuf)		 ;;;;;;;
			else
				editbuf = BinaryAlloc(1000)
				BinaryPokeStr(editbuf,0,"[rename]%@CRLF%")
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hdexe),@CRLF))
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hddll),@CRLF))
				BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(hdinf),@CRLF))
				BinaryWrite( editbuf, wininit)
				BinaryFree(editbuf)
			endif
	    endif
	
	;and run setup program from temp, passing parameters
	Exclusive(@OFF)
	RunShell(hdexe,strcat(`91 "`,logfile,`"`),temp,@NORMAL,@NOWAIT)
	exit
	break;
	
case 91 
    TimeDelay(4)
	WinActivate("")
	WinZoom("")
	BoxNew(Noteid,rectu,1)
	BoxColor(Noteid,LTGRAY,0)	; Light Gray no gradient
	BoxDrawRect(Noteid,"",2)
	BoxTextFont(Noteid,"Arial",uHeight,0,0)	  ; san-srif, ariel, size 12, nobold, noitalic
	BoxTextColor(Noteid,BLUE)
	BoxDataTag(Noteid,"NOTE")
	BoxDrawText(Noteid,rectutext,"Uninstall Proceeding...",1,4)
	
	IniWritePvt("Setup Data","Status",2,infname)
	RestartRequired=@FALSE
	RebootRequired=@FALSE
	NewFileNameUsed=@FALSE
	FinishLog=@FALSE
	loglog=""
	keywordsmain="DIR DONE FILE SHORTCUT NEWINSTALL NOTE REG PROGMAN DIRSYSTEM"
	logfile=param2
	if !FileExist(logfile)
	   Message("Error",strcat("Log file",@crlf,logfile,@crlf,"required to uninstall.                                                                                          File was not found."))
	   exit
	endif

   ;Nuke HKEY_CURRENT_USER\Software\%regsection%\ type stuff here
   for xx = 1 to 10
      iniitem="a:curruserapp%xx%"
      gosub GetSetupItem
      if a=="XXX" then break
      key=strcat("Software\%regsection%\",a)
      if RegExistKey(@RegCurrent,key)
         ErrorMode(@off)
         RegDeleteKey(@RegCurrent,key)
         ErrorMode(@cancel)
      endif
   next

   ;Nuke container key if empty.
   if RegExistKey(@RegCurrent,"Software\%regsection%")
      key=RegOpenKey(@RegCurrent,"Software\%regsection%")
      a=RegQueryKeys(key)
      RegCloseKey(key)
      if a=="" then RegDeleteKey(@RegCurrent,"Software\%regsection%")
   endif
   ;End of HKEY_CURRENT_USER nuking.

	logsize=FileSize(logfile)
	logbin=BinaryAlloc(logsize+2)
	BinaryRead(logbin,logfile)
	loglast=logsize
	logfirst=logsize
	
       SheetHappens=@FALSE
       while logfirst	; March thru file in reverse trying to kill stuff off
	   logfirst=BinaryIndex(logbin, loglast, @CRLF, @backscan)
	   if (logfirst+2)!=loglast
	      
	      if logfirst==0 then yy=0
			     else yy=2
	      logline=BinaryPeekStr(logbin,logfirst+yy,loglast-logfirst-yy)
	   ;Message("Remove",logline)
	   ParseData(logline)
	   keynum=ItemLocate(param1,keywordsmain," ")
	  
	   LastError()
	   switch keynum
	   case 1 ; DIR
		BoxTextColor(Noteid,BLUE)
		BoxDataClear(Noteid,"NOTE")
		BoxDrawText(Noteid,rectuText,"Removing Dir %param3%",1,4)
		if dbgnorem then break 
		if !DirExist(param3) then break	 ; its already goned
		Errormode(@OFF)
		DirRemove(param3)
		err=LastError()
		if err
		    SheetHappens=@TRUE
		    log=strcat("DirRemove Failed(%err%): ",FilePath(param3),@CRLF)
		    if strlen(loglog)>=strlen(log)
		       if strindex(strupper(loglog),strupper(log),1,@fwdscan)==0 then loglog=strcat(loglog,log)
		    else
		       loglog=strcat(loglog,log)
		    endif
		endif
		ErrorMode(@CANCEL)
		break
		
	   case 2 ; DONE
		; Ignored
		break
		
	   case 3 ; FILE
	   case 4 ; SHORTCUT
		BoxTextColor(Noteid,BLUE)
		BoxDataClear(Noteid,"NOTE")
		BoxDrawText(Noteid,rectuText,"Removing File %param3%",1,4)
		if dbgnorem then break
		killpath=strupper(FilePath(param3))
		x1=strupper(DirWindows(0))
		if x1==killpath then break ; ignore stuff in win
		x2=strupper(DirWindows(1))
		if x2==killpath then break  ; ignore stuff in system
		;if keynum==4 then param3=strcat(FilePath(param3),fileroot(param3))
		if StrScan(param3,"*?",1,@FWDSCAN)==0	; a mask??
		   if !FileExist(param3) then break   ; No mask, File Exist??
		endif
		if FileExtension(param3)=="*" 
		    Message("Error in log file #65",param3)
		    exit
		endif
		ErrorMode(@OFF)
		FileAttrSet(param3,"rash")
		FileDelete(param3)
		err=LastError()
		ErrorMode(@CANCEL)
		if ((err!=1016 && err!=0 && err!=1002)||(err==1016 && FileExist(param3)))    ;arrgg  file in use.  Kill it
		    x=WinMetrics(-4)   ; Win95 or NT
		    if x==4    ;Windows NT
		       IntControl(30, param3, "", 0, 0) ;KillMoveonReboot		       
		       RebootRequired=@TRUE
		    endif
		    if x==5   ; Windows 95
			ErrorMode(@OFF)
			LastError()
			x2=FileNameShort(param3) ; Get Short Name
			if !LastError()
				wininit= strcat(DirWindows(0),"WININIT.INI")
				if FileExist(wininit)
					fs1=FileSize(wininit)
					srcbuf	= BinaryAlloc(fs1+2000)
					editbuf = BinaryAlloc(fs1+2000)
					BinaryRead( srcbuf, wininit)
					a = BinaryIndex( srcbuf, 0, "rename]", @FWDSCAN)
					if a==0 then a = BinaryIndex( srcbuf, 0, "Rename]", @FWDSCAN)
					if a==0 then a = BinaryIndex( srcbuf, 0, "RENAME]", @FWDSCAN)
					if a==0
					   BinaryPokeStr(srcbuf,fs1,"[rename]%@CRLF%  %@CRLF%")
					   a=fs
					else
					   a=a-1
					endif
					cuthere = BinaryIndex( srcbuf, a, @CRLF, @FWDSCAN) + 2
					BinaryCopy( editbuf, 0, srcbuf, 0, cuthere)
					BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(param3),@CRLF))
					a = BinaryEodGet(editbuf)
					b = BinaryEodGet(srcbuf)
					BinaryCopy( editbuf, a, srcbuf, cuthere, b-cuthere)
					BinaryWrite( editbuf, wininit)
					BinaryFree(editbuf)
					BinaryFree(srcbuf)		 ;;;;;;;
				else
					editbuf = BinaryAlloc(1000)
					BinaryPokeStr(editbuf,0,"[rename]%@CRLF%")
					BinaryPokeStr(editbuf,BinaryEodGet(editbuf), Strcat("NUL=",FileNameShort(param3),@CRLF))
					BinaryWrite( editbuf, wininit)
					BinaryFree(editbuf)
				endif
				RestartRequired=@TRUE
			    endif
		    endif
		else
		    if (err!=0 && err!=1002)
			    log=strcat("FileRemove failed(%err%): ",FilePath(param3),@CRLF)
			    if strlen(loglog)>=strlen(log)
			       if strindex(strupper(loglog),strupper(log),1,@fwdscan)==0 then loglog=strcat(loglog,log)
			    else
			       loglog=strcat(loglog,log)
			    endif
			    SheetHappens=@TRUE
		    endif
		endif
		break
		
		
		
	   case 5 ; NEWINSTALL
	   case 6 ; NOTE
		;ignore
		break
		
	   case 7 ; REG
		; Remove registration database entries
		if dbgnorem then break


		bigkey=param3
		bigkey=%bigkey%
		
		if param2=="ITEM"
		    subkey="%param4%"
		    item=strlower("%param5%")
		    if item=="[Default]" then item="[]"
		    ErrorMode(@OFF)
		    LastError()
		    ;Pause("REG ITEM %bigkey%",strcat(subkey,@crlf,item))
		    if WIN32
		       rkey=RegOpenKey(bigkey,subkey) 
		       err=LastError()
		       if err==0
			  RegDelValue(rkey,item)
			  RegCloseKey(rkey)
		       endif
		    endif
		    ErrorMode(@CANCEL)
		else
		    if param2=="KEY"
		       subkey=param4
		       killkey=param5
		       ErrorMode(@OFF)
		       LastError()
		       ;Pause("REG KEY %bigkey%",strcat(subkey,@crlf,killkey))
		       rkey=RegOpenKey(bigkey,subkey) 
		       err=LastError()
		       if err==0
			  RegDeleteKey(rkey,killkey)
			  RegCloseKey(rkey)
		       endif
		       ErrorMode(@CANCEL)
		       ;Message("reg key did it?",strcat(subkey,@crlf,killkey))
		    else
			if param2=="WWW"
			   subkey=param4
			   killkey=param5
			   ErrorMode(@OFF)
			   LastError()
			   ;message("logline",logline)
			   ;Determine if anyone under WWW (we just deleted one)
			   rkey=RegOpenKey(bigkey,strcat(subkey,"\",killkey))
			   err=LastError()
			   if err==0
			      b=RegQueryKey(rkey,0)
			      c=RegQueryKey(rkey,1)
			      RegCloseKey(rkey)
			      ;Pause("REG KEY1 %bigkey%",strcat(subkey,"\",killkey,@crlf,"b=",b))
			   
			      if ((b=="") || (b=="Settings" && c==""))
				 rkey=RegOpenKey(bigkey,subkey) 
				 err=LastError()
				 if err==0
				      ;Pause("REG KEY2 %bigkey%",strcat(subkey,@crlf,killkey))
				      RegDeleteKey(rkey,killkey)
				      RegCloseKey(rkey)
				 endif
			      endif
			   endif
			   ErrorMode(@CANCEL)
			else
			   Message("Hmmm","Unrecognised registry code %param2%")
			endif
		    endif
		endif
		break
		
		case 8	 ;PROGMAN
			if dbgnorem then break
			Exclusive(@OFF)
			AX=DDEInitiate("Progman", "Progman")
			IF AX==0    ; Hmmm nobody's home
                            run("progman.exe","")
                            timedelay(4)
                            AX=DDEInitiate("Progman", "Progman")
                        endif
                        if AX!=0
                           if param2=="GROUP"
                              DDEExecute(AX,"[DeleteGroup(%param3%)]")    ; ignore error return
                           else
                              if param2=="ICON"
                                   DDEExecute(AX,"[DeleteItem(%param3%)]")  ;Ignore error return
                                   ;Add the item.     
                              endif
                           endif
                           DDETerminate(AX)
                        endif
                        WinActivate("")
                        Exclusive(@ON)
                break


					 case 9 ; DIRSYSTEM
				        ;Clear Eval control codes
				        sectionname=IniReadPvt("Setup Data","sectionname","Unknown",infname) ;Get sectionname
				        ;Message(sectionname,dirsystem)  ;debug
						  ;param2 should be dirsystem
					 break
           endswitch
           
           
           endif ; have apparently valid data to moosh
           loglast=logfirst
        endwhile   ; marching backwards thru log file
        BinaryFree(logbin)
        BoxTextColor(Noteid,BLUE)
        BoxDataClear(Noteid,"NOTE")
        BoxDrawText(Noteid,rectuText,"Uninstall Complete",1,4)




        ;kill off final pieces here
        if SheetHappens
           Message("Could not uninstall all items, as shown",loglog)
        endif
        if RebootRequired || RestartRequired
           SetState=8
           break
        else
           exit
        endif
       ; Code should never get here  #2
       Message("Hmmm 2","Internal Error %param1% %param2%")
       exit
        

case 95
        Message("Don't Run Me","This setup data marked for deletion on next reboot.")
        exit

case SetState
        Message("Ummm Bad case",SetState)
        break

end switch
end while

; Code should never get here  #3
Message("Hmmm 3","Internal Error %param1% %param2%")
exit



Article ID:   W15280
File Created: 2002:09:05:13:51:02
Last Updated: 2002:09:05:13:51:02