VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsExternal.nsh

Last change on this file was 108772, checked in by vboxsync, 3 weeks ago

Windows Guest Additions installer: Big revamp of the overall source code structure to (hopefully) make it a lot more clear and removed code duplication. There has been a lot of code rot being accumulated over the last decade. Added lots of missing and fixes for documentation. Also revamped the installed files structure so that we have component sub folders to make it more clear which file belongs to what. Older Guest Additions will be migrated automatically. Tested upgrades with 7.1, 7.0 and 6.1 Guest Additions. bugref:10881

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1; $Id: VBoxGuestAdditionsExternal.nsh 108772 2025-03-27 15:32:33Z vboxsync $
2;; @file
3; VBoxGuestAdditionExternal.nsh - Utility function for invoking external applications.
4;
5
6;
7; Copyright (C) 2013-2024 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; SPDX-License-Identifier: GPL-3.0-only
26;
27
28
29;;
30; Macro for executing external applications.
31;
32; Uses the nsExec plugin in different styles, depending on whether this
33; installer runs in silent mode or not. If the external program reports an exit
34; code other than 0 the installer will be aborted.
35;
36; @param ${cmdline} Command line (full qualified and quoted).
37; @param ${options} Either 'non-zero-exitcode=log' or 'non-zero-exitcode=abort'.
38; Controls how to handle non-zero exit codes, in the latter
39; case they will trigger an installation abort, while in the
40; form only a warning in the log file.
41;
42!macro _cmdExecute cmdline options
43 ; Save $0 & $1
44 Push $0
45 Push $1
46
47 ; Check that the options are valid.
48 ${If} ${options} != "non-zero-exitcode=log"
49 ${AndIf} ${options} != "non-zero-exitcode=abort"
50 Abort "Internal error in _cmdExecute: options=${options} cmdline=${cmdline}"
51 ${EndIf}
52
53 ;
54 ; Execute the command, putting the exit code in $0 when done.
55 ;
56 ${LogVerbose} "Executing: ${cmdline}"
57 ${If} ${Silent}
58 nsExec::ExecToStack "${cmdline}"
59 Pop $0 ; Return value (exit code)
60 Pop $1 ; Stdout/stderr output (up to ${NSIS_MAX_STRLEN})
61 ${LogVerbose} "exit code=$0: $1"
62 ${Else}
63 nsExec::ExecToLog "${cmdline}"
64 Pop $0 ; Return value (exit code)
65 ${EndIf}
66
67 ${LogVerbose} "Execution returned exit code: $0"
68
69 ;
70 ; Check if it failed and take action according to the 2nd argument.
71 ;
72 ${If} $0 <> 0
73 ${OrIf} $0 == "error" ; Issued by the nsExec plugin if the DLL call failed (messy handling within nsExec, sigh).
74 ${If} ${options} == "non-zero-exitcode=abort"
75 ${LogVerbose} "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
76 Abort "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
77 ${Else}
78 ${LogVerbose} "Warning: Executing $\"${cmdline}$\" returned with exit code $0"
79 ${EndIf}
80 ${EndIf}
81
82 ; Restore $0 and $1.
83 Pop $1
84 Pop $0
85!macroend
86!define CmdExecute "!insertmacro _cmdExecute"
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette