@@ -35,7 +35,7 @@ setcompressor /SOLID lzma
35
35
!define VC_VERSION " VC143"
36
36
37
37
; Use Modern UI
38
- !include " MUI .nsh"
38
+ !include " MUI2 .nsh"
39
39
ICON " install-ocs.ico"
40
40
; MUI Settings
41
41
!define MUI_HEADERIMAGE
@@ -66,8 +66,10 @@ Page custom AskLocalInventory ValidateLocalInventory ""
66
66
!define MUI_FINISHPAGE_RUN_TEXT " Start OCS Inventory NG Systray Applet"
67
67
!define MUI_FINISHPAGE_RUN " $INSTDIR\OcsSystray.exe"
68
68
!insertmacro MUI_PAGE_FINISH
69
- ; Confirl before uninstall
69
+
70
+ UninstPage custom un.AskUninstallOptions un.ValidateUninstallOptions " "
70
71
!insertmacro MUI_UNPAGE_INSTFILES
72
+
71
73
; Language files
72
74
!insertmacro MUI_LANGUAGE " English"
73
75
!insertmacro MUI_LANGUAGE " French"
@@ -110,7 +112,12 @@ var /GLOBAL OcsNoSplash ; To store if setup must display spash screen (FALSE) or
110
112
var /GLOBAL OcsUpgrade ; To store if /UPGRADE option used (TRUE) or not (FALSE)
111
113
var /GLOBAL installSatus ; To store installation status
112
114
var /GLOBAL OcsLocal ; To store folder where to write local inventory file
113
-
115
+ ; handle uninstall variables
116
+ var /GLOBAL hCtl
117
+ var /GLOBAL hCtl_uninstalloptions
118
+ var /GLOBAL hCtl_clean
119
+ var /GLOBAL hCtl_Label1
120
+ var /GLOBAL uninstallOption ; To store the uninstall option
114
121
# ####################################################################
115
122
# GetParameters
116
123
# input, none
@@ -322,6 +329,121 @@ done:
322
329
Exch $R1
323
330
FunctionEnd
324
331
332
+ Function un.GetParameters
333
+ Push $R0
334
+ Push $R1
335
+ Push $R2
336
+ Push $R3
337
+
338
+ StrCpy $R2 1
339
+ StrLen $R3 $CMDLINE
340
+
341
+ ; Check for quote or space
342
+ StrCpy $R0 $CMDLINE $R2
343
+ StrCmp $R0 ' "' 0 +3
344
+ StrCpy $R1 ' "'
345
+ Goto loop
346
+ StrCpy $R1 " "
347
+
348
+ loop:
349
+ IntOp $R2 $R2 + 1
350
+ StrCpy $R0 $CMDLINE 1 $R2
351
+ StrCmp $R0 $R1 get
352
+ StrCmp $R2 $R3 get
353
+ Goto loop
354
+
355
+ get:
356
+ IntOp $R2 $R2 + 1
357
+ StrCpy $R0 $CMDLINE 1 $R2
358
+ StrCmp $R0 " " get
359
+ StrCpy $R0 $CMDLINE " " $R2
360
+
361
+ Pop $R3
362
+ Pop $R2
363
+ Pop $R1
364
+ Exch $R0
365
+ FunctionEnd
366
+
367
+ Function un.GetParameterValue
368
+ Exch $R0 ; get the top of the stack(default parameter) into R0
369
+ Exch ; exchange the top of the stack(default) with
370
+ ; the second in the stack(parameter to search for)
371
+ Exch $R1 ; get the top of the stack(search parameter) into $R1
372
+
373
+ ; Preserve on the stack the registers used in this function
374
+ Push $R2
375
+ Push $R3
376
+ Push $R4
377
+ Push $R5
378
+
379
+ Strlen $R2 $R1 ; store the length of the search string into R2
380
+
381
+ Call un.GetParameters ; get the command line parameters
382
+ Pop $R3 ; store the command line string in R3
383
+
384
+ # search for quoted search string
385
+ StrCpy $R5 ' "' ; later on we want to search for a open quote
386
+ Push $R3 ; push the 'search in' string onto the stack
387
+ Push ' "$R1' ; push the 'search for'
388
+ Call un.StrStr ; search for the quoted parameter value
389
+ Pop $R4
390
+ StrCpy $R4 $R4 " " 1 ; skip over open quote character, "" means no maxlen
391
+ StrCmp $R4 " " " " next ; if we didn't find an empty string go to next
392
+
393
+ # search for non-quoted search string
394
+ StrCpy $R5 ' ' ; later on we want to search for a space since we
395
+ ; didn't start with an open quote '"' we shouldn't
396
+ ; look for a close quote '"'
397
+ Push $R3 ; push the command line back on the stack for searching
398
+ Push ' $R1' ; search for the non-quoted search string
399
+ Call un.StrStr
400
+ Pop $R4
401
+
402
+ ; $R4 now contains the parameter string starting at the search string,
403
+ ; if it was found
404
+ next:
405
+ StrCmp $R4 " " check_for_switch ; if we didn't find anything then look for
406
+ ; usage as a command line switch
407
+ # copy the value after $R1 by using StrCpy with an offset of $R2,
408
+ # the length of 'OUTPUT'
409
+ StrCpy $R0 $R4 " " $R2 ; copy commandline text beyond parameter into $R0
410
+ # search for the next parameter so we can trim this extra text off
411
+ Push $R0
412
+ Push $R5 ; search for either the first space ' ', or the first
413
+ ; quote '"'
414
+ ; if we found '"/output' then we want to find the
415
+ ; ending ", as in '"/output=somevalue"'
416
+ ; if we found '/output' then we want to find the first
417
+ ; space after '/output=somevalue'
418
+ Call un.StrStr ; search for the next parameter
419
+ Pop $R4
420
+ StrCmp $R4 " " done ; if 'somevalue' is missing, we are done
421
+ StrLen $R4 $R4 ; get the length of 'somevalue' so we can copy this
422
+ ; text into our output buffer
423
+ StrCpy $R0 $R0 -$R4 ; using the length of the string beyond the value,
424
+ ; copy only the value into $R0
425
+ goto done ; if we are in the parameter retrieval path skip over
426
+ ; the check for a command line switch
427
+
428
+ ; See if the parameter was specified as a command line switch, like '/output'
429
+ check_for_switch:
430
+ Push $R3 ; push the command line back on the stack for searching
431
+ Push ' $R1' ; search for the non-quoted search string
432
+ Call un.StrStr
433
+ Pop $R4
434
+ StrCmp $R4 " " done ; if we didn't find anything then use the default
435
+ StrCpy $R0 " " ; otherwise copy in an empty string since we found the
436
+ ; parameter, just didn't find a value
437
+
438
+ done:
439
+ Pop $R5
440
+ Pop $R4
441
+ Pop $R3
442
+ Pop $R2
443
+ Pop $R1
444
+ Exch $R0 ; put the value in $R0 at the top of the stack
445
+ FunctionEnd
446
+
325
447
# ####################################################################
326
448
# This function write content of logBuffer variable in log file in
327
449
# a log file OcsAgentSetup.log located in install directory
@@ -580,7 +702,7 @@ ParseCmd_NoSystray_End:
580
702
WriteINIStr " $PLUGINSDIR\agent.ini" " Field 9" " State" " 0"
581
703
goto ParseCmd_Now_End
582
704
ParseCmd_Now:
583
- ; Immediately maunch inventory
705
+ ; Immediately launch inventory
584
706
WriteINIStr " $PLUGINSDIR\agent.ini" " Field 9" " State" " 1"
585
707
ParseCmd_Now_End:
586
708
; Remove parsed arg from command line
@@ -1397,6 +1519,39 @@ FunctionEnd
1397
1519
Function ValidateAgent2Options
1398
1520
FunctionEnd
1399
1521
1522
+ Function un.AskUninstallOptions
1523
+ ; === test (type: Dialog) ===
1524
+ nsDialogs::Create 1018
1525
+ Pop $hCtl
1526
+ ${If} $hCtl == error
1527
+ Abort
1528
+ ${EndIf}
1529
+ !insertmacro MUI_HEADER_TEXT " OCS Inventory NG Agent uninstaller" " You are about to uninstall OCS Inventory NG Agent ${PRODUCT_VERSION}, select uninstall option below..."
1530
+
1531
+ ; === uninstalloptions (type: GroupBox) ===
1532
+ ${NSD_CreateGroupBox} 8u 7u 280u 126u " Uninstall option"
1533
+ Pop $hCtl_uninstalloptions
1534
+
1535
+ ; === clean (type: DropList) ===
1536
+ ${NSD_CreateDropList} 12u 41u 195u 13u " NONE"
1537
+ Pop $hCtl_clean
1538
+ ${NSD_CB_AddString} $hCtl_clean " NONE"
1539
+ ${NSD_CB_AddString} $hCtl_clean " ONLY CONFIGURATION FILES"
1540
+ ${NSD_CB_AddString} $hCtl_clean " ALL FILES"
1541
+ ${NSD_CB_SelectString} $hCtl_clean " NONE"
1542
+
1543
+ ; === Label1 (type: Label) ===
1544
+ ${NSD_CreateLabel} 12u 25u 205u 14u " Do you want to remove persistent files from OCS Inventory ?"
1545
+ Pop $hCtl_Label1
1546
+
1547
+ nsDialogs::Show
1548
+ FunctionEnd
1549
+
1550
+ Function un.ValidateUninstallOptions
1551
+ ${NSD_GetText} $hCtl_clean $0
1552
+ StrCpy $uninstallOption " $0"
1553
+ FunctionEnd
1554
+
1400
1555
Function AskLocalInventory
1401
1556
${If} ${SectionIsSelected} 4 ; Index of Local inventory section
1402
1557
!insertmacro MUI_HEADER_TEXT " OCS Inventory Agent for Windows" " Choose folder to save inventory result..."
@@ -1994,8 +2149,6 @@ Function un.onInit
1994
2149
Pop $R9
1995
2150
StrLen $0 $R9
1996
2151
IntCmp $0 2 unOnInit_silent 0 unOnInit_silent
1997
- MessageBox MB_ICONQUESTION |MB_YESNO |MB_DEFBUTTON2 " Are you sure to uninstall $(^Name)?" IDYES +2
1998
- Abort
1999
2152
unOnInit_silent:
2000
2153
FunctionEnd
2001
2154
@@ -2033,6 +2186,23 @@ Section Uninstall
2033
2186
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} " ${PRODUCT_UNINST_KEY}"
2034
2187
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} " ${OLD_PRODUCT_UNINST_KEY}"
2035
2188
DeleteRegKey HKLM " ${PRODUCT_DIR_REGKEY}"
2189
+ ; Get clean paramater
2190
+ Push " /CLEAN=" ; push the search string onto the stack
2191
+ Push " NONE" ; push a default value onto the stack
2192
+ Call un.GetParameterValue
2193
+ Pop $2
2194
+
2195
+ ${If} $2 == " ALL"
2196
+ ${OrIf} $uninstallOption == " ALL FILES"
2197
+ RMDir /r /REBOOTOK " $APPDATA\OCS Inventory NG"
2198
+ ${EndIf}
2199
+
2200
+ ${If} $2 == " FILES"
2201
+ ${OrIf} $uninstallOption == " ONLY CONFIGURATION FILES"
2202
+ RMDir /r /REBOOTOK " $APPDATA\OCS Inventory NG\Agent\Download"
2203
+ Delete /REBOOTOK " $APPDATA\OCS Inventory NG\Agent\ocsinventory.ini"
2204
+ ${EndIf}
2205
+
2036
2206
SetAutoClose true
2037
2207
SectionEnd
2038
2208
@@ -2053,4 +2223,4 @@ Function un.onUninstSuccess
2053
2223
unOnUninstSuccess_silent:
2054
2224
StrCpy $logBuffer " ${PRODUCT_NAME} ${PRODUCT_VERSION} was successfully uninstalled."
2055
2225
Call un.Write_Log
2056
- FunctionEnd
2226
+ FunctionEnd
0 commit comments