diff options
| author | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2014-03-03 10:23:19 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@zerotier.com> | 2014-03-03 10:23:19 -0800 |
| commit | cef750d1d222c839b796d1898352b9ccd5dcab51 (patch) | |
| tree | 1a84f1646e9eebfa37e5384a1115f7fcd61069c7 /main.cpp | |
| parent | be36eda8585ae33572656471da009b023cc610dc (diff) | |
| download | infinitytier-cef750d1d222c839b796d1898352b9ccd5dcab51.tar.gz infinitytier-cef750d1d222c839b796d1898352b9ccd5dcab51.zip | |
Add option to install drivers in driver cache on Windows, needed for Windows installer. Blech.
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -42,6 +42,7 @@ #include <tchar.h> #include <wchar.h> #include <lmcons.h> +#include <newdev.h> #include "windows/ZeroTierOne/ServiceInstaller.h" #include "windows/ZeroTierOne/ServiceBase.h" #include "windows/ZeroTierOne/ZeroTierOneService.h" @@ -100,6 +101,7 @@ static void printHelp(const char *cn,FILE *out) fprintf(out," -C - Run from command line instead of as service (Windows)"ZT_EOL_S); fprintf(out," -I - Install Windows service (Windows)"ZT_EOL_S); fprintf(out," -R - Uninstall Windows service (Windows)"ZT_EOL_S); + fprintf(out," -D - Load tap driver into system driver store (Windows)"ZT_EOL_S); #endif } @@ -579,6 +581,22 @@ int main(int argc,char **argv) } return 0; } break; + case 'D': { // install Windows driver (since PNPUTIL.EXE seems to be weirdly unreliable) + std::string pathToInf; +#ifdef _WIN64 + pathToInf = ZT_DEFAULTS.defaultHomePath + "\\tap-windows\\x64\\zttap200.inf"; +#else + pathToInf = ZT_DEFAULTS.defaultHomePath + "\\tap-windows\\x86\\zttap200.inf"; +#endif + BOOL needReboot = FALSE; + if (DiInstallDriverA(NULL,pathToInf.c_str(),DIIRFLAG_FORCE_INF,&needReboot)) { + fprintf(stderr,"%s: driver successfully installed from %s"ZT_EOL_S,argv[0],pathToInf.c_str()); + return 0; + } else { + fprintf(stderr,"%s: failed installing %s: %d"ZT_EOL_S,argv[0],pathToInf.c_str(),(int)GetLastError()); + return 3; + } + } break; #endif // __WINDOWS__ case 'h': case '?': |
