Private Sub ActiveReport_ReportStart()
Dim strSql As String
Dim sql As String
lblNamaBank.Caption = xLoginLembaga & " - " & xLoginCabang
lblAlamatBank.Caption = xLoginCabangAlamat & " Telp. " & xLoginCabangTelp
lblJudul.Caption = "NOMINATIF LAPORAN ANALISA KREDIT"
lblPeriode.Caption = "Periode " & Format(frmReportAnalisa.dtAnalisa1.Value, "dd mmmm yyyy") & _
" s.d " & Format(frmReportAnalisa.dtAnalisa2.Value, "dd mmmm yyyy")
lblDicetak.Caption = "Dicetak oleh " & xLoginNama & ", Tanggal " & Format(Now, "dd-mm-yyyy") & _
", Jam " & Format(Now, "hh:mm:ss")
With frmReportAnalisa
If .txtKdKantor.Text <> "" Then _
sql = sql & " AND pengajuan_kantor = '" & .txtKdKantor.Text & "'"
If .txtKdSkim.Text <> "" Then _
sql = sql & " AND analisa_jenis_skim = '" & .txtKdSkim.Text & "'"
If .txtKdJenis.Text <> "" Then _
sql = sql & " AND analisa_jenis_kredit = '" & .txtKdJenis.Text & "'"
If .txtKdBunga.Text <> "" Then _
sql = sql & " AND analisa_sistem_bunga = '" & .txtKdBunga.Text & "'"
If .txtKdAngsuran.Text <> "" Then _
sql = sql & " AND analisa_sistem_angsuran = '" & .txtKdAngsuran.Text & "'"
If .txtKdCS.Text <> "" Then _
sql = sql & " AND pengajuan_reg_alias = '" & SplitText(.cboCS.Text, ":", 2) & "'"
If .txtKdKolektor.Text <> "" Then _
sql = sql & " AND pelengkap_kode_kolektor = '" & .txtKdKolektor.Text & "'"
If .txtKdAnalisa.Text <> "" Then _
sql = sql & " AND kredit_metode = '" & .txtKdAnalisa.Text & "'"
If .txtPlafon1.Text <> "0" And .txtPlafon2.Text <> "0" Then _
sql = sql & " AND analisa_plafon BETWEEN " & CCur(.txtPlafon1.Text) & " AND " & CCur(.txtPlafon2.Text) & " "
End With
strSql = "SELECT pengajuan_regnumber, pengajuan_register, pengajuan_kantor, pengajuan_tanggal_registrasi, kredit_metode, " & _
"kredit_skor_akhir, analisa_bunga, analisa_jkw, kredit_tgl_analisa, kredit_rekomendasi, " & _
"analisa_jenis_kredit, analisa_plafon, pengajuan_reg_alias, analisa_sistem_bunga, pengajuan_tanggal_kunjungan, " & _
"analisa_sistem_angsuran, analisa_jenis_skim, pelengkap_kode_avalis, pelengkap_kode_kolektor, kredit_regnumber, " & _
"pelengkap_kode_wilayah, pelengkap_kode_wilayah2, pelengkap_notaris_kode, pelengkap_kode_avalis, " & _
"GetNamaKolektor(pelengkap_kode_kolektor, left(pengajuan_regnumber, 2)) as NamaKolektor, " & _
"GetSistemBunga(analisa_sistem_bunga) as SistemBunga, " & _
"GetAnalisaMetode(kredit_metode) as MetodeAnalisa, " & _
"GetSistemAngsuran(analisa_sistem_angsuran) as SistemAngsuran, " & _
"GetNasabahNama(pengajuan_register) as NamaNasabah, " & _
"GetAlamat(pengajuan_register) as AlamatNasabah " & _
"FROM data_kredit_skor " & _
"LEFT JOIN data_kredit_analisa ON analisa_regnumber = kredit_regnumber " & _
"LEFT JOIN data_kredit_pengajuan ON pengajuan_regnumber = kredit_regnumber " & _
"LEFT JOIN data_kredit_pelengkap ON pelengkap_rekening = kredit_regnumber " & _
"WHERE 1 = 1 AND kredit_status = '1' AND (kredit_tgl_analisa " & _
"BETWEEN '" & Format(frmReportAnalisa.dtAnalisa1.Value, "yyyy-mm-dd") & "' " & _
"AND '" & Format(frmReportAnalisa.dtAnalisa2.Value, "yyyy-mm-dd") & "') " & sql
RunSQL strSql
End Sub
Private Sub ActiveReport_FetchData(EOF As Boolean)
On Error Resume Next
If rsNew.EOF = True Then Exit Sub
EOF = False
Screen.MousePointer = 11
lblNo.Caption = Val(lblNo.Caption) + 1
lblNoPengajuan.Caption = rsNew.Fields("pengajuan_regnumber")
lblNama.Caption = " " & rsNew.Fields("NamaNasabah")
lblAlamat.Caption = " " & rsNew.Fields("AlamatNasabah")
lblTglPengajuan.Caption = Format(rsNew.Fields("pengajuan_tanggal_registrasi"), "dd-mm-yyyy")
lblTglAnalisa.Caption = Format(rsNew.Fields("kredit_tgl_analisa"), "dd-mm-yyyy")
lblAnalisa.Caption = " " & rsNew.Fields("MetodeAnalisa")
lblSkim.Caption = rsNew.Fields("analisa_jenis_skim")
lblJenis.Caption = rsNew.Fields("analisa_jenis_kredit")
lblSistemBunga.Caption = rsNew.Fields("SistemBunga")
lblSistemAngsuran.Caption = rsNew.Fields("SistemAngsuran")
lblPlafon.Caption = Format(rsNew.Fields("analisa_plafon"), "#,##0") & " "
lblTotal.Caption = Val(Replace(lblTotal.Caption, ".", "")) + Val(Replace(lblPlafon.Caption, ".", ""))
lblTotal.Caption = Format(lblTotal.Caption, "#,##0") & " "
lblBunga.Caption = rsNew.Fields("analisa_bunga") & " %"
lblJkw.Caption = rsNew.Fields("analisa_jkw")
lblKolektor.Caption = rsNew.Fields("NamaKolektor")
lblSkor.Caption = Replace(rsNew.Fields("kredit_skor_akhir"), ".", ",") & " % "
lblKet.Caption = rsNew.Fields("kredit_rekomendasi")
If lblKet.Caption = "TIDAK LAYAK" Then lblKet.Caption = "TIDAK"
rsNew.MoveNext
Screen.MousePointer = 0
End Sub
Report dengan Active report
Small Script
'Front Critical
If MsgBox("Apakah yakin akan menghapus : " & xxx & "", _
vbCritical + vbYesNo, Me.Caption) = vbYes Then
'Call proccedure
dB.Execute "CALL `db`.`procedure_name('" & xIdKredit & "')
Export ke excel
' EXPORT TO EXCEL
If ListView1.ListItems.Count = 0 Then
MsgBox "Tidak ada data!", vbExclamation, App.Title
exit sub
End If
XLSFILENAME = ""
With Me.cd1
.Filter = "Excel Workbook (.xls)"
.ShowSave
XLSFILENAME = .filename
End With
If XLSFILENAME = "" Then
Exit Sub
End If
Call ExportListview(ListView1, XLSFILENAME)
MsgBox "Export sukses!", vbInformation, App.Title
XLSFILENAME = ""
Untuk mengcapitalkan isi textbox
Sub CapitalTb()
Dim oText(100) As String
Dim i As Integer
For Each obj In Me.Controls
If Left(obj.Name, 3) = "txt" Then
obj.Text = UCase(obj.Text)
obj.Text = Replace(obj.Text, "'", "`")
End If
Next
End Sub
Vb Script - 2
Function HanyaAngka(ByRef KeyAscii As Integer)
If ((KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57) Then
MsgBox "Isilah dengan angka!", vbExclamation, App.Title
KeyAscii = 0
End If
End Function
Function HijriDate()
Dim xTgl As String
Dim xHijri As String
Dim days As DayConstants
xTgl = Format(xLoginDate, "yyyy-mm-dd")
days = Date - CDate(xTgl)
days = days + 1
DateTime.Calendar = vbCalHijri
xHijri = Format(Date - days, "dd-mm-yyyy")
xSistemHijriDate = xHijri
If Mid(xHijri, 4, 2) = "01" Then xHijri = Replace(xHijri, "-01-", " Muharram ")
If Mid(xHijri, 4, 2) = "02" Then xHijri = Replace(xHijri, "-02-", " Safar ")
If Mid(xHijri, 4, 2) = "03" Then xHijri = Replace(xHijri, "-03-", " Rabiul Awal ")
If Mid(xHijri, 4, 2) = "04" Then xHijri = Replace(xHijri, "-04-", " Rabiul Akhir ")
If Mid(xHijri, 4, 2) = "05" Then xHijri = Replace(xHijri, "-05-", " Jumadal Ula ")
If Mid(xHijri, 4, 2) = "06" Then xHijri = Replace(xHijri, "-06-", " Jumadal Tsani ")
If Mid(xHijri, 4, 2) = "07" Then xHijri = Replace(xHijri, "-07-", " Rajab ")
If Mid(xHijri, 4, 2) = "08" Then xHijri = Replace(xHijri, "-08-", " Sya'ban ")
If Mid(xHijri, 4, 2) = "09" Then xHijri = Replace(xHijri, "-09-", " Ramadhan ")
If Mid(xHijri, 4, 2) = "10" Then xHijri = Replace(xHijri, "-10-", " Syawwal ")
If Mid(xHijri, 4, 2) = "11" Then xHijri = Replace(xHijri, "-11-", " Dzulkaidah ")
If Mid(xHijri, 4, 2) = "12" Then xHijri = Replace(xHijri, "-12-", " Dzulhijjah ")
xLoginHijri = xHijri
DateTime.Calendar = vbCalGreg
End Function
Function CpuId() As String
Dim computer As String
Dim wmi As Variant
Dim processors As Variant
Dim cpu As Variant
Dim cpu_ids As String
computer = "."
Set wmi = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
computer & "\root\cimv2")
Set processors = wmi.ExecQuery("Select * from " & _
"Win32_Processor")
For Each cpu In processors
cpu_ids = cpu_ids & ", " & cpu.ProcessorID
Next cpu
If Len(cpu_ids) > 0 Then cpu_ids = Mid$(cpu_ids, 3)
CpuId = cpu_ids
End Function
VB Script - 1
Sub TreeALL()
Dim nodX As Node
Dim nodX2 As Node
Dim s As String
Dim i As Long
Dim xParent As Long
Dim xParent2 As Long
nMenu = 0
For Each obj In frmMain.Controls
If Left(obj.Name, 2) = "mn" Then
If Mid(obj.Name, 3, 1) = "0" Then menuName(nMenu) = Mid(obj.Name, 4, 10)
If Mid(obj.Name, 3, 1) = "1" Then menuName(nMenu) = Mid(obj.Name, 3, 10)
menuCaption(nMenu) = Replace(obj.Caption, "&", "")
menuCaption(nMenu) = obj.Name & ". " & SplitText(menuCaption(nMenu), ".", 2)
menuCaption(nMenu) = Replace(menuCaption(nMenu), "mn", "")
nMenu = nMenu + 1
End If
Next
For i = 0 To nMenu - 1
If Len(menuName(i)) = 1 Then
xParent = Left(menuName(i), 1)
Set nodX = treeview1.Nodes.Add(, , "mn" & xParent, menuCaption(i))
nodX.Checked = False
nodX.Expanded = True
ElseIf Len(menuName(i)) = 2 Then
xParent = Left(menuName(i), 2)
Set nodX = treeview1.Nodes.Add(, , "mn" & xParent, menuCaption(i))
nodX.Checked = False
nodX.Expanded = True
ElseIf Len(menuName(i)) > 2 And Len(menuName(i)) < 5 Then
Set nodX = treeview1.Nodes.Add("mn" & xParent, tvwChild, , menuCaption(i))
nodX.Checked = False
nodX.Expanded = True
ElseIf Len(menuName(i)) = 5 Then
Set nodX2 = treeview1.Nodes.Add(nodX, tvwChild, , menuCaption(i))
nodX2.Checked = False
nodX2.Expanded = True
End If
Next
treeview1.BorderStyle = vbFixedSingle
Call TreeBold
End Sub
Sub TreeGroup()
Dim i As Integer
Dim j As Integer
Dim xMenuGroup As String
Dim xMenuMaster As String
For i = 1 To Me.ListView1.ListItems.Count
xMenuGroup = Me.ListView1.ListItems.Item(i).ListSubItems(2).Text
For j = 1 To Me.treeview1.Nodes.Count
xMenuMaster = SplitText(Me.treeview1.Nodes.Item(j).Text, ".", 1)
If xMenuGroup = xMenuMaster Then Me.treeview1.Nodes.Item(j).Checked = True
Next
Next
End Sub
Sub TreeBold()
Dim i As Integer
For i = 1 To Me.treeview1.Nodes.Count
If Len(SplitText(Me.treeview1.Nodes(i).Text, ".", 1)) = 2 Then Me.treeview1.Nodes(i).Bold = True
Next
End Sub
Backup dan Restore Database MySQL dari Aplikasi
Untuk proses backup kita cukup menggunakan tool bawaan MySQL yaitu mysqldump dan untuk restorenya menggunakan mysql.
Adapun perintah dasar untuk melakukan backup dan restore adalah sebagai berikut :
1 | ' backup |
2 | mysqldump -uUSER_NAME -pUSER_PASSWORD --routines NAMA_DATABASE > LOKASI_FILE_BACKUP.SQL |
3 |
4 | ' restore |
5 | mysql -uUSER_NAME -pUSER_PASSWORD NAMA_DATABASE < LOKASI_FILE_BACKUP.SQL |
parameter –routines ditambahkan jika database mempunyai fungsi/trigger
Sekarang tinggal kita siapkan kode berikut :
01 | Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long |
02 | Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long |
03 | Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long |
04 |
05 | Private Const SYNCHRONIZE As Long = &H100000 |
06 | Private Const INFINITE As Long = &HFFFF |
07 |
08 | Private Sub execCommand(ByVal cmd As String) |
09 | Dim result As Long |
10 | Dim lPid As Long |
11 | Dim lHnd As Long |
12 | Dim lRet As Long |
13 |
14 | cmd = "cmd /c " & cmd |
15 | result = Shell(cmd, vbHide) |
16 |
17 | lPid = result |
18 | If lPid <> 0 Then |
19 | lHnd = OpenProcess(SYNCHRONIZE, 0, lPid) |
20 | If lHnd <> 0 Then |
21 | lRet = WaitForSingleObject(lHnd, INFINITE) |
22 | CloseHandle (lHnd) |
23 | End If |
24 | End If |
25 | End Sub |
kemudian tinggal panggil di masing-masing proses (backup dan restore)
01 | Dim cmd As String |
02 |
03 | Private Sub cmdBackup_Click() |
04 | Screen.MousePointer = vbHourglass |
05 | DoEvents |
06 |
07 | cmd = Chr(34) & "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump" & Chr(34) & " -uroot -prahasia --routines --comments nama_database > c:\nama_database.sql" |
08 | Call execCommand(cmd) |
09 |
10 | Screen.MousePointer = vbDefault |
11 | MsgBox "done" |
12 | End Sub |
13 |
14 | Private Sub cmdRestore_Click() |
15 | Screen.MousePointer = vbHourglass |
16 | DoEvents |
17 |
18 | cmd = Chr(34) & "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql" & Chr(34) & " -uroot -prahasia --comments nama_database < c:\nama_database.sql" |
19 | Call execCommand(cmd) |
20 |
21 | Screen.MousePointer = vbDefault |
22 | MsgBox "done" |
23 | End Sub |
kode diatas dengan asumsi direktori bin MySQL ada di folder “C:\Program Files\MySQL\MySQL Server 5.1\bin”.
Selamat mencoba sumber
Membuat paket instalasi vb + mysql dengan NSIS
NSIS adalah salah satu tool gratis dan open source untuk membuat paket instalasi. Oke sebelum kita melangkah lebih jauh, berikut adalah hal-hal yang perlu kita persiapkan :
- NSIS
- MySQL versi noninstall disesuaikan dengan versi MySQL yang terinstall di komputer Anda
- Connector ODBC yang sudah terinstall biasanya ada di C:\Program Files\MySQL\Connector ODBC 5.1
- Database yang sudah di backup/dump
- Untuk editor, bagi Anda yang buta warna cukup pake notepad
, saya sendiri menggunakan notepad++ atau kalo pengen lebih nyaman bisa menggunakan eclipse kemudian download plug-in NSIS
Memang kalo dilihat dari segi skrip, Inno Setup lebih simple dibandingkan NSIS tetapi setelah saya bandingkan hasil paket instalasi NSIS lebih kecil dibandingkan Inno Setup.
Skrip Inno Setup dan NSIS sama-sama dikelompokkan dalam section-section bedanya kalo Inno Setup untuk nama sectionnya sudah fix (misal Setup, Tasks, Files de el el) sedangkan NSIS untuk nama sectionnya bebas dan tentunya dalam penamaan section di NSIS disesuaikan dengan isinya (misal Install MySQL 5).
Salah satu bagian penting dari skrip NSIS yang kita bahas disini adalah skrip yang digunakan untuk membuat service MySQL, mendaftarkan driver MySQL Connector ODBC dan melakukan proses undump skrip databse (.sql).
Saya ambil contoh untuk membuat service MySQL tentunya dilihat dari versi windows yang terinstall kalo keluarga Win9x jelas tidak bisa karena belum mendukung pembuatan service, oleh karena itu sebelum menjalankan perintah membuat service akan dilakukan pengecekan versi windows terlebih dulu.
Nah disini akan terlihat jelas perbedaan skrip Inno Setup dan NSIS dimana untuk melakukan ini inno setup cukup menambahkan flag MinVersion, misal :
1 | [Run] |
2 | ;mysqld --install MySQL |
3 | Filename: "{app}\mysql\bin\mysqld.exe"; Parameters: "install ""MySQL"""; StatusMsg: "Sedang menginstall service MySQL ..."; Flags: runhidden; MinVersion: 0,5.01.2600sp2; Tasks: installmysql |
Sedangkan untuk NSIS kita perlu mendownload Version plug-in terlebih dulu dan mengekstraknya kemudiakan mengcopykan file version.dll ke folder instalasi NSIS\Plugins, walaupun sebenarnya kita bisa membuat fungsi sendiri di NSIS untuk mengecek versi windows yang terinstall.
Contoh skrip NSIS untuk mengecek versi windows dan menginstall service MySQL :
01 | Section "Install MySQL 5" |
02 | Version::IsWindowsXP |
03 |
04 | Pop $0 ;nilai var $0 akan bersisi 1 jika windows XP selain itu 0 |
05 | StrCmp $0 "1" ItIsWindowsXP ItIsNotWindowsXP ;StrCmp sama seperti fungsi IIF di VB |
06 |
07 | ItIsWindowsXP: |
08 | Goto installservice |
09 |
10 | ItIsNotWindowsXP: |
11 | Goto done |
12 |
13 | installservice: |
14 | DetailPrint "Sedang menginstall service MySQL ..." |
15 | ExecWait '"$MYSQL_DIR\bin\mysqld.exe" install "MySQL"' |
16 |
17 | done: |
18 | ;do nothing |
19 | SectionEnd |
Gimana lumayan beda kan?
Khusus untuk file-file Runtime VB memerlukan penanganan khusus dan untuk memudahkan Anda mencoba sample skrip ini download terlebih dahulu file Runtime VB disini dan jangan lupa diekstrak.
Persiapan terakhir untuk struktur folder saya buat seperti berikut :
Dan saya tidak akan menjelaskan fungsi-fungsi/perintah yang digunakan dalam skrip NSIS karena sudah saya sisipkan komentar di sample skrip instalasi NSIS.
Jika masih kesulitan Anda bisa langsung membaca manual NSIS yang penjelasannya sudah sangat lengkap.
Berikut contoh skrip instalasi lengkap menggunakan NSIS :
001 | ;Skrip instalasi by k4m4r82 |
002 | ;http://coding4ever.wordpress.com |
003 |
004 | !include VB6RunTime.nsh |
005 |
006 | ;deklarasi konstanta |
007 | ;format pemanggilan ${NAMA_KONSTANTA} |
008 | !define APP_NAME "Sistem Pembelian Bahan Baku PT. ALBASI" |
009 | !define APP_PUBLISHER "K4m4r82's Laboratory" |
010 | !define APP_VERSION "2.0.50" |
011 |
012 | BrandingText /TRIMCENTER "-- ${APP_PUBLISHER} --" |
013 | Name "${APP_NAME} ${APP_VERSION}" |
014 | Caption "${APP_NAME} ${APP_VERSION}" |
015 |
016 | CompletedText "Instalasi sudah selesai" |
017 |
018 | Icon "setup.ico" |
019 | LoadLanguageFile "${NSISDIR}\Contrib\Language files\Indonesian.nlf" |
020 | OutFile "output\DemoSetupNSIS.exe" |
021 | ShowInstDetails show |
022 | ShowUninstDetails show |
023 | WindowIcon on |
024 | XPStyle on |
025 |
026 | ;informasi default folder instalasi |
027 | InstallDir "$PROGRAMFILES\SPBB" |
028 |
029 | ;informasi folder instalasi disimpan disini |
030 | ;informasi ini akan memudahkan kita untuk membuat program update |
031 | InstallDirRegKey HKCU "Software\PT ALBASI\SPBB" "InstallDir" |
032 |
033 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "ProductName" "${APP_NAME}" |
034 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "Comments" "" |
035 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "CompanyName" "${APP_PUBLISHER}" |
036 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "LegalTrademarks" "${APP_NAME} is a trademark of ${APP_PUBLISHER}" |
037 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "LegalCopyright" "Copyright © 2009. ${APP_PUBLISHER}" |
038 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "FileDescription" "${APP_NAME}" |
039 | VIAddVersionKey /LANG=${LANG_INDONESIAN} "FileVersion" "2.0.0.50" |
040 | VIProductVersion "2.0.0.50" |
041 |
042 | RequestExecutionLevel admin |
043 |
044 | AddBrandingImage left 150|234 |
045 | Page custom BrandingImage |
046 | Page components |
047 | Page directory |
048 | Page instfiles |
049 |
050 | UninstPage custom un.BrandingImage |
051 | UninstPage uninstConfirm |
052 | UninstPage instfiles |
053 |
054 | ;deklarsi variabel |
055 | ;format pemanggilan $NAMA_VARIABEL ingat ada sedikit perbedaan dg konstanta |
056 | Var MainDir |
057 | Var MySQLDir |
058 | Var AlreadyInstalled |
059 |
060 | ;section yang diawali karakter -, pilihannya tidak ditampilkan |
061 | Section "-Inisialisasi Variabel" |
062 | StrCpy $MainDir $INSTDIR |
063 | StrCpy $MySQLDir $MainDir\mysql |
064 | SectionEnd |
065 |
066 | Section "-Visual Basic Runtime" |
067 | ;download file Visual Basic Runtime di: http://nsis.sourceforge.net/vb6runtime.zip |
068 | IfFileExists "$MainDir\Albasi.exe" 0 new_installation |
069 | StrCpy $AlreadyInstalled 1 |
070 |
071 | new_installation: |
072 | !insertmacro VB6RunTimeInstall "dll&ocx\vb6runtime" $AlreadyInstalled |
073 | SectionEnd |
074 |
075 | Section "-My Application Runtime" |
076 | SetOutPath $MainDir |
077 | File "main\Albasi.exe.manifest" |
078 | File "main\Albasi.exe" |
079 |
080 | SetOutPath $SYSDIR |
081 |
082 | File "dll&ocx\LVbuttons.OCX" |
083 | RegDLL "$SYSDIR\LVbuttons.ocx" |
084 |
085 | File "dll&ocx\MSMASK32.OCX" |
086 | RegDLL "$SYSDIR\MSMASK32.ocx" |
087 |
088 | File "dll&ocx\cTreeOpt6.ocx" |
089 | RegDLL "$SYSDIR\cTreeOpt6.ocx" |
090 |
091 | File "dll&ocx\Comdlg32.ocx" |
092 | RegDLL "$SYSDIR\Comdlg32.ocx" |
093 |
094 | File "dll&ocx\vbalDTab6.ocx" |
095 | RegDLL "$SYSDIR\vbalDTab6.ocx" |
096 |
097 | File "dll&ocx\vbalExpBar6.ocx" |
098 | RegDLL "$SYSDIR\vbalExpBar6.ocx" |
099 |
100 | File "dll&ocx\MSCOMCTL.OCX" |
101 | RegDLL "$SYSDIR\MSCOMCTL.ocx" |
102 |
103 | File "dll&ocx\vbalIml6.ocx" |
104 | RegDLL "$SYSDIR\vbalIml6.ocx" |
105 |
106 | File "dll&ocx\cPopMenu6.ocx" |
107 | RegDLL "$SYSDIR\cPopMenu6.ocx" |
108 |
109 | File "dll&ocx\cNewMenu6.dll" |
110 | RegDLL "$SYSDIR\cNewMenu6.DLL" |
111 |
112 | File "dll&ocx\scrrun.dll" |
113 | RegDLL "$SYSDIR\scrrun.DLL" |
114 |
115 | File "dll&ocx\vbalMDITabs6.dll" |
116 | RegDLL "$SYSDIR\vbalMDITabs6.DLL" |
117 |
118 | File "dll&ocx\SSubTmr6.dll" |
119 | RegDLL "$SYSDIR\SSubTmr6.DLL" |
120 |
121 | File "dll&ocx\msado21.tlb" |
122 | RegDLL "$SYSDIR\msado21.tlb" |
123 | SectionEnd |
124 |
125 | ; param /e -> expand |
126 | SectionGroup /e "Komponen Server" |
127 | Section "Install MySQL 5" |
128 | ; param /r -> recursive |
129 | SetOutPath $MySQLDir\bin |
130 | File /r "mysql-5.1.36-win32\bin\*.*" |
131 |
132 | SetOutPath $MySQLDir\Docs |
133 | File /r "mysql-5.1.36-win32\Docs\*.*" |
134 |
135 | SetOutPath $MySQLDir\lib |
136 | File /r "mysql-5.1.36-win32\lib\*.*" |
137 |
138 | SetOutPath $MySQLDir\share |
139 | File /r "mysql-5.1.36-win32\share\*.*" |
140 |
141 | SetOutPath $MySQLDir\data |
142 | File /r "mysql-5.1.36-win32\data\*.*" |
143 |
144 | SetOutPath $MySQLDir |
145 | File "mysql-5.1.36-win32\*.*" |
146 |
147 | ;informasi lokasi instalasi mysql |
148 | WriteINIStr $MySQLDir\my.ini "mysqld" "basedir" $MySQLDir |
149 | WriteINIStr $MySQLDir\my.ini "mysqld" "datadir" $MySQLDir\data |
150 |
151 | ;proses membuat dan menjalankan service mysql, cek versi windows terlebih dulu |
152 | ;untuk contoh disini baru di tes untuk windows xp sp2 |
153 | Version::IsWindowsXP |
154 |
155 | Pop $0 ;nilai var $0 akan bersisi 1 jika windows XP selain itu 0 |
156 | StrCmp $0 "1" ItIsWindowsXP ItIsNotWindowsXP ;StrCmp sama seperti fungsi IIF di VB |
157 |
158 | ItIsWindowsXP: |
159 | Goto installservice |
160 |
161 | ItIsNotWindowsXP: |
162 | Goto done |
163 |
164 | installservice: |
165 | DetailPrint "Sedang menginstall service MySQL ..." |
166 | ExecWait '"$MySQLDir\bin\mysqld.exe" install "MySQL"' |
167 |
168 | ;jalankan service MySQL |
169 | DetailPrint "Sedang menjalankan service MySQL ..." |
170 | ExecWait '"$SYSDIR\net.exe" start "MySQL"' |
171 |
172 | ;mendaftarkan port default mysql (3306) ke firewall |
173 | DetailPrint "Sedang mendaftarkan port MySQL ..." |
174 | ExecWait '"$SYSDIR\netsh.exe" firewall add portopening TCP 3306 "Port MySQL"' |
175 |
176 | ;mengganti password default root (blank). ex : masterkey |
177 | DetailPrint "Mengganti password root" |
178 | ExecWait '"$MySQLDir\bin\mysqladmin.exe" -uroot password masterkey' |
179 |
180 | ;menghapus user default1 (user=blank, password=blank) |
181 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "DELETE FROM mysql.user WHERE Host=$\'localhost$\' AND User=$\'$\'"' |
182 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "FLUSH PRIVILEGES"' |
183 |
184 | ;menghapus user default2 (user=root, password=blank) |
185 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "DELETE FROM mysql.user WHERE Host=$\'127.0.0.1$\' AND User=$\'root$\'"' |
186 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "FLUSH PRIVILEGES"' |
187 |
188 | ;set agar user root bisa login dari mesin lain (kalo diperlukan) |
189 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "GRANT ALL PRIVILEGES ON *.* TO root@$\'%$\' IDENTIFIED BY $\'masterkey$\'"' |
190 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "FLUSH PRIVILEGES"' |
191 |
192 | done: |
193 | ;do nothing |
194 | SectionEnd |
195 |
196 | Section "Install MySQL Connector ODBC" |
197 | SetOutPath $SYSDIR |
198 |
199 | ;dll mysql odbc tidak perlu diregistrasikan |
200 | ;jadi otomatis tidak perlu memanggil fungsi RegDLL |
201 | File "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.dll" |
202 | File "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5S.dll" |
203 | File "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.lib" |
204 | File "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5S.lib" |
205 | File "C:\Program Files\MySQL\Connector ODBC 5.1\myodbc-installer.exe" |
206 |
207 | Version::IsWindowsXP |
208 |
209 | Pop $0 |
210 | StrCmp $0 "1" ItIsWindowsXP ItIsNotWindowsXP |
211 |
212 | ItIsWindowsXP: |
213 | Goto installdriverodbc |
214 |
215 | ItIsNotWindowsXP: |
216 | Goto done |
217 |
218 | installdriverodbc: |
219 | ;install driver myodbc |
220 | DetailPrint "Tunggu sedang mendaftarkan driver MySQL Connector ODBC 5.1.5" |
221 | ExecWait '"$SYSDIR\myodbc-installer.exe" -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"' |
222 |
223 | done: |
224 | ;do nothing |
225 | SectionEnd |
226 |
227 | Section "Install Database" |
228 | SetOutPath $MySQLDir\bin |
229 |
230 | File "main\albasi.sql" |
231 | File "main\exec.cmd" |
232 |
233 | Version::IsWindowsXP |
234 |
235 | Pop $0 |
236 | StrCmp $0 "1" ItIsWindowsXP ItIsNotWindowsXP |
237 |
238 | ItIsWindowsXP: |
239 | Goto installdatabase |
240 |
241 | ItIsNotWindowsXP: |
242 | Goto done |
243 |
244 | installdatabase: |
245 | ;membuat database kosong |
246 | ExecWait '"$MySQLDir\bin\mysql.exe" -uroot -pmasterkey -e "CREATE DATABASE albasi"' |
247 |
248 | ;menjalankan file batch exec.cmd untuk melakukan proses undump |
249 | ExecWait '"$MySQLDir\bin\exec.cmd"' |
250 |
251 | done: |
252 | ;do nothing |
253 | SectionEnd |
254 | SectionGroupEnd |
255 |
256 | SectionGroup /e "Buat Shortcut" |
257 | Section "Start Programs" |
258 | SectionIn RO ;RO -> Read Only |
259 |
260 | CreateDirectory "$SMPROGRAMS\PT. ALBASI" |
261 | CreateShortCut "$SMPROGRAMS\PT. ALBASI\${APP_NAME}.lnk" "$MainDir\Albasi.exe" "" "$MainDir\Albasi.exe" 0 |
262 | SectionEnd |
263 |
264 | Section "Desktop" |
265 | ;CreateDirectory "$DESKTOP\SPBB" |
266 | CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$MainDir\Albasi.exe" "" "$MainDir\Albasi.exe" 0 |
267 | SectionEnd |
268 |
269 | Section "Quick Launch" |
270 | ;CreateDirectory "$QUICKLAUNCH\SPBB" |
271 | CreateShortCut "$QUICKLAUNCH\${APP_NAME}.lnk" "$MainDir\Albasi.exe" "" "$MainDir\Albasi.exe" 0 |
272 | SectionEnd |
273 | SectionGroupEnd |
274 |
275 | Section "-Registry Windows" |
276 | ;informasi uninstall |
277 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" "DisplayName" "${APP_NAME}" |
278 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" "UninstallString" '"$MainDir\uninstaller.exe"' |
279 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" "DisplayIcon" '"$MainDir\uninstaller.exe"' |
280 |
281 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" "NoModify" 1 |
282 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" "NoRepair" 1 |
283 |
284 | WriteUninstaller $MainDir\uninstaller.exe |
285 | SectionEnd |
286 |
287 | Section "-File Konfigurasi Program" |
288 | WriteINIStr $MainDir\infoprogram.ini "Sistem" "serverName" "127.0.0.1" |
289 | WriteINIStr $MainDir\infoprogram.ini "Sistem" "dbName" "albasi" |
290 | SectionEnd |
291 |
292 | Section "Uninstall" |
293 | ;stop service MySQL |
294 | DetailPrint "Menghentikan Service MySQL ..." |
295 | ExecWait '"$SYSDIR\net.exe" stop "MySQL"' |
296 |
297 | ;hapus service MySQL |
298 | DetailPrint "Sedang menghapus service MySQL ..." |
299 | ExecWait '"$MySQLDir\bin\mysqld.exe" remove "MySQL"' |
300 |
301 | ;driver MySQL Connector ODBC 5.1 |
302 | DetailPrint "Tunggu sedang menghapus driver MySQL Connector ODBC 5.1" |
303 | ExecWait '"$SYSDIR\myodbc-installer.exe" -d -r -n "MySQL ODBC 5.1 Driver"' |
304 |
305 | ; Remove registry keys |
306 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SPBB" |
307 |
308 | ; Remove files and uninstaller |
309 | Delete $MainDir\*.* |
310 | RMDir $MainDir |
311 |
312 | ; Remove shortcuts |
313 | Delete "$SMPROGRAMS\PT. ALBASI\*.*" |
314 | RMDir "$SMPROGRAMS\PT. ALBASI" |
315 |
316 | Delete "$DESKTOP\${APP_NAME}.lnk" |
317 | Delete "$QUICKLAUNCH\${APP_NAME}.lnk" |
318 | SectionEnd |
319 |
320 | ;fungsi untuk menampilkan gambar/banner pada saat instalasi |
321 | ;untuk contoh disini posisi gambar di sebelah kiri |
322 | Function BrandingImage |
323 | SetOutPath "$TEMP" |
324 |
325 | SetFileAttributes SetupModern21.bmp temporary |
326 | File SetupModern21.bmp |
327 | SetBrandingImage "$TEMP\SetupModern21.bmp" /resizetofit |
328 | FunctionEnd |
329 |
330 | ;fungsi untuk menampilkan gambar/banner pada saat uninstall |
331 | Function un.BrandingImage |
332 | SetBrandingImage "$TEMP\SetupModern21.bmp" /resizetofit |
333 | FunctionEnd |
Di dalam skrip instalasi ada file exec.cmd, isinya adalah :
1 | mysql -uroot -pmasterkey albasi < albasi.sql |
Isi file exec.cmd sebenarnya untuk proses undump dan ternyata Inno Setup dan NSIS gagal menjalankan perintah tersebut, padahal perintah-perintah yang lainnya sukses.
Contoh hasil instalasi :
Gambar 1
Gambar 2
Gambar 3
Gambar 4
Selamat mencoba





