Office 97 Installation Sample Code
Keywords: Office 97 Installation Sample Code
; I hope this gives you a good headstart
; The best thing to do is open it in Winbatch Studio
; and step through it to see what every line does.
; Once you have seen the functionality of the waitturn subroutine
; it's easier to step over it
AddExtender("wwctl34I.dll")
jn=AskYesNo("Do you wish to install Office 97?","This routine will install everything")
if jn <> @yes then Return
setup="r:\Office97\SETUP.EXE"
If Param0
instpart=Param1
instdir=Param2
If Param3=="reboot" ; this is not applicable here, but it might be for other routines
reboot=@true
Else
reboot=@false
Endif
Else
instpart="C:"
instdir="\Program Files\Microsoft Office"
Endif
instpath=strcat(instpart,instdir)
sysdir = Environment("SYSTEMROOT")
program="Office 97"
pace=0
run(setup,"")
if !DirExist("C:\instlogs") then DirMake("C:\instlogs")
loghandle=fileopen("C:\instlogs\Office97.txt","write")
FileWrite(loghandle,"[%program%]")
FileWrite(loghandle,Timedate())
title="Microsoft Office 97 Setup"
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
MouseClickBtn(title,child,"Continue")
child="Name and Organization Information"
timeout=-1
gosub waitturn
SendKeysTo(title,"!nAbis") ;Name
SendKeysTo(title,"!oAbis") ;Organization
MouseClickBtn(title,child,"OK")
child="Confirm Name and Organization Information"
timeout=-1
gosub waitturn
MouseClickBtn(title,child,"OK")
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
SendKeysTo(title,"!c04011234567") ; CD-key (I replaced this with a dummy. It doesn't need a TAB character between the two parts)
MouseClickBtn(title,child,"OK")
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
MouseClickBtn(title,child,"OK")
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
TimeDelay(5)
MouseClickBtn(title,child,"Change Folder...")
child="Change Folder"
timeout=-1
gosub waitturn
SendKeysTo(title,"!p%path%") ; path
MouseClickBtn(title,child,"OK")
title="Microsoft Office 97 Setup"
child="The destination folder:"
timeout=5
gosub waitturn
if c then MouseClickBtn(title,"","Yes")
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
MouseClickBtn(title,child,"OK")
child="Microsoft Office 97 Setup"
timeout=-1
gosub waitturn
TimeDelay(5)
openwnd=DllHwnd(title)
chldwnd=cWndByName(openwnd,child)
buttonwnd=cWndByID(chldwnd,15) ; 14 &Typical 15 &Custom 16 &Run from CD-ROM
cClickButton(buttonwnd)
child="Microsoft Office 97 - Custom"
timeout=-1
gosub waitturn
SendKeysTo(title,"!o{HOME}") ; Options
; Here you might try to select what you need, I haven't come round to that part yet as it is destined at temporary installations anyway
; so I just installed the whole lot
; An alternative would be to stop execution temporarily with:
Message("Please Select what you want to install","Press OK, when you are ready")
;SendKeysTo(title,"!s") ; Select All
MouseClickBtn(title,child,"Continue")
child="Select Paper Format and Language"
timeout=6
gosub waitturn
If c then SendKeysTo(title,"aa") ; British English Dictionaries
; You will be able to find out how to select your own dictionaries, I'm sure
MouseClickBtn(title,child,"OK")
child="Default Web Page Editor"
timeout=6
gosub waitturn
If c then MouseClickBtn(title,child,"No")
child="Microsoft Office 97"
timeout=-1
gosub waitturn
TimeDelay(5)
child="Microsoft Office 97"
timeout=30
gosub waitturn
If c then MouseClickBtn(title,child,"OK")
FileWrite(loghandle,Timedate())
FileClose(loghandle)
Return
:waitturn
t=WinWaitExist(title, timeout)
IF child<>"" then c=WinWaitChild(title,child,timeout)
TimeDelay(pace)
FileWrite(loghandle,title)
FileWrite(loghandle,child)
return
Article ID: W13789
Filename: Office 97 Installation Sample Code.txt