1 | /* $Id: VBoxNetAdpUninstall.cpp 62688 2016-07-29 13:30:27Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NetAdpUninstall - VBoxNetAdp uninstaller command line tool
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include <VBox/VBoxNetCfg-win.h>
|
---|
19 | #include <VBox/VBoxDrvCfg-win.h>
|
---|
20 | #include <stdio.h>
|
---|
21 |
|
---|
22 | #include <devguid.h>
|
---|
23 |
|
---|
24 | #ifdef NDIS60
|
---|
25 | #define VBOX_NETADP_HWID L"sun_VBoxNetAdp6"
|
---|
26 | #else /* !NDIS60 */
|
---|
27 | #define VBOX_NETADP_HWID L"sun_VBoxNetAdp"
|
---|
28 | #endif /* !NDIS60 */
|
---|
29 |
|
---|
30 | static VOID winNetCfgLogger (LPCSTR szString)
|
---|
31 | {
|
---|
32 | printf("%s", szString);
|
---|
33 | }
|
---|
34 |
|
---|
35 | static int VBoxNetAdpUninstall()
|
---|
36 | {
|
---|
37 | int r = 1;
|
---|
38 | VBoxNetCfgWinSetLogging(winNetCfgLogger);
|
---|
39 |
|
---|
40 | printf("uninstalling all Host-Only interfaces..\n");
|
---|
41 |
|
---|
42 | HRESULT hr = CoInitialize(NULL);
|
---|
43 | if (hr == S_OK)
|
---|
44 | {
|
---|
45 | hr = VBoxNetCfgWinRemoveAllNetDevicesOfId(VBOX_NETADP_HWID);
|
---|
46 | if (hr == S_OK)
|
---|
47 | {
|
---|
48 | hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", VBOX_NETADP_HWID, 0/* could be SUOI_FORCEDELETE */);
|
---|
49 | if (hr == S_OK)
|
---|
50 | {
|
---|
51 | printf("uninstalled successfully\n");
|
---|
52 | }
|
---|
53 | else
|
---|
54 | {
|
---|
55 | printf("uninstalled successfully, but failed to remove infs\n");
|
---|
56 | }
|
---|
57 | r = 0;
|
---|
58 | }
|
---|
59 | else
|
---|
60 | {
|
---|
61 | printf("uninstall failed, hr = 0x%x\n", hr);
|
---|
62 | }
|
---|
63 |
|
---|
64 | CoUninitialize();
|
---|
65 | }
|
---|
66 | else
|
---|
67 | {
|
---|
68 | wprintf(L"Error initializing COM (0x%x)\n", hr);
|
---|
69 | }
|
---|
70 |
|
---|
71 | VBoxNetCfgWinSetLogging(NULL);
|
---|
72 |
|
---|
73 | return r;
|
---|
74 | }
|
---|
75 |
|
---|
76 | int __cdecl main(int argc, char **argv)
|
---|
77 | {
|
---|
78 | RT_NOREF2(argc, argv);
|
---|
79 | return VBoxNetAdpUninstall();
|
---|
80 | }
|
---|