Win7
Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech
-
- OpenVpn Newbie
- Posts: 12
- Joined: Sun Feb 27, 2011 3:18 pm
Re: Win7
Okay I figured this one out. The driver files can be stolen from the 2.2 install and copied into any of the older version installs. You can open the 2.2 .exe installer file with 7zip, and copy files out at will. Once I figured that out, it was a matter of determining what needed to be copied over. Mostly driver files, executables, ad DLL's. I modified the installer script accordingly, and made sure it also added the config/cert files I needed added. I compiled, and was able to get some stuff working. One of these days, I'll post more details.
-S
-S
-
- Forum Team
- Posts: 285
- Joined: Wed Aug 27, 2008 2:41 am
Re: Win7
I'll look forward to that, I'm sure others will also.schnibitz wrote:Okay I figured this one out. The driver files can be stolen from the 2.2 install and copied into any of the older version installs. You can open the 2.2 .exe installer file with 7zip, and copy files out at will. Once I figured that out, it was a matter of determining what needed to be copied over. Mostly driver files, executables, ad DLL's. I modified the installer script accordingly, and made sure it also added the config/cert files I needed added. I compiled, and was able to get some stuff working. One of these days, I'll post more details.
-S
-
- OpenVpn Newbie
- Posts: 12
- Joined: Sun Feb 27, 2011 3:18 pm
Re: Win7
Okay so to be TOTALLY honest the best I can provide at this point is a general means of getting this to work. I'll get as specific as I can, where I can but although I can describe the steps involved, I didn't document exact paths, names and such.
This assumes you'll be doing all of this on a Windows machine, specifically in my case Windows 7.
Before you get started, make sure you install 7zip:
http://www.7-zip.org/download.html
Next download:
openvpn-2.2-beta5-install.exe
from http://swupdate.openvpn.net/community/r ... nstall.exe
Other versions MIGHT work, I don't know I haven't tested.
Next download: http://www.openvpn.se/files/install_pac ... beta26.zip
Again, other versions might work, but that's just the one that I used.
Finally download and install the NSIS install system here:
http://nsis.sourceforge.net/download
You'll be using this shortly but a little background.
The instructions here: http://openvpn.se/files/howto/openvpn-h ... ckage.html
presumably work for windows xp. I don't know I haven't tried it on XP, I'm using Windows 7. The problem with Windows 7 is that it expects the drivers to be made differently. The 2.2 installer (above) has a driver that Windows 7 likes (near as I can tell). I've been using it for testing quite a bit. The 2.0 Beta driver doesn't seem to work well, and I don't see any source for 2.2 available on any of the sites.
So what we have to do is steal guts from the 2.2 Beta install, and put them into the 2.0 install package. The only other option is to just create an install script of our own from scratch, and hope it works (which is too much work for me).
So that solves the problem with the driver but in my testing with the client, I was using directives that only 2.2 beta can recognize. When openvpn 2.0 beta tried to read the directives in the config file, it threw all sorts of errors. So we have to swap the guts of openvpn.exe, and it's various DLL files as well.
Note: I am using my install for a very specific purpose. I am using password auth on the server, so I don't have any clue if the openssl certificate stuff is behaving correctly in this install. Just a word of caution.
Get started by opening 7zip. In 7zip, browse to the location of where you downloaded your openvpn-2.2-beta5-install.exe. Right-click that file, choose 7zip, and "open archive". 7Zip will show you all the files in that installer now.
Cool huh?
So the first thing we want to accomplish is copying/replacing the files necessary to install the TAP interface. This guide does not deal with the hidden interface BTW. So in the 7zip archive window, double-click "driver". On my machine I saw 6 files there, 3 of which were dupes. Don't ask me why, I don't know, but I only dealt with the first three. So we have to put those files in the 2.0 installer source. So we unzip that installer, and make note of where it is. Then we open up the unzipped 2.0 installer. The first folder you should see in that unzipped archive is "openvpn". Double-click on that, and then you'll see a lot more folders. This is where all the "guts" of that installer is. Dive into tap-32, then i386. Now you want to drag the first three files from the 2.2 archive into this folder. 7zip will extract them, and copy them over to the i386 folder. If it asks you to replace, say "yes".
In the end there will be the following files:
OemWin2k.inf
tap0801.sys
tap0901.cat
tap0901.sys
There is another file involved in the installation of this driver, and to be honest I'm not even sure this step is necessary but I did it anyway.
In your 2.2 installer archive, go back up a folder to the root of the install. You do that by deleting "driver" in the address bar. That will take you back to the root of the install dir hopefully. A folder named "bin" is anxiously awaiting your arrival. Go there.
Notice there is a "tapinstall.exe" in there along with a number of other goodies. Pick one of the "tapinstall.exe" files (I honestly don't know which one. I see two when I'm looking at it). Drag one of them over to the "bin" folder in your 2.0 install source. I don't think there is one there by default, but if there is, say yes when it asks you to replace. Next double-click the "ti3790" folder, and drag the same tapinstall.exe from the 2.2 to that folder as well, and confirm replace.
So now we've taken care of PART of problem1. That's the TAP driver. To finish fixing this problem, we need to make changes to the installer code. So we need to get back to the top level of the install source files/folders. You'll see a script there called "openvpn-gui.nsi". Using notepad, open that puppy up. Now change the following lines:
to
Next make sure you do a search in that file for lines with "tapinstall.exe". Look for something that has a "setoutpath" and "setoverwrite" line. I don't remember exactly what it looks like but mine ended up like this:
Now technically the way I coded that up is wrong. It takes the file from the ti3790 folder in the install source, and copies it to the \bin dir on the computer.
The silly thing is that I think the ti3790 isn't even necessary because it doesn't even show up on my computer after it is installed. Again this is what worked for me. I encourage people brighter and more patient than I am to clean this up and make it more clear. The essential bit is above though okay? Make sure that's in the installer code, and save that code but don't close it out. We'll need it again several more times.
So we've now fixed Problem1, which is the tap driver (in theory). Now when this installs, it will give you warnings about unsigned drivers, and it will also give you a compatibility warning too. Just click to not show the warnings again, and choose run. It will work. Actually you may not even see that warning at all, I don't know. I did, but I horsed around a lot with these installers, so some of their junk could have interfered.
Problem2
This may not even be a problem for you but it was for me. The .ovbn file I created has directives compatible with the 2.2 version of the openvpn.exe. So I had to replace those files as well. If your syntax is 2.0 compatible, you can likely totally skip this part. I'm not 100% sure of that but I believe that's the case.
So what we have to do now is find the related items from the 2.2 installer, and just like in problem1, copy them over, and replace files as necessary. Then modify the installer script so that it knows what's up. Sound good?
So head on over to the 2.2 archive window. We want to make sure we're in the installer's "bin" directory. If you're not already there, please get there.
Next find the "bin" directory in the 2.0 install, and have that open and available. Now drag the following files from 2.2 to the 2.0 install source bin folder.
libeay32.dll
libpkcs22-helper-1.dll
libssl32.dll
Make sure you replace what's in the 2.0 bin dir with those files.
Next we want to copy over the openvpn.exe file. That file goes in the root of the install dir. Why that works as opposed to being in the BIN dir I don't know. As a matter of fact, it probably WOULD work in the bin folder but the install script likes it in the root of the install folder as you'll see shortly. So navigate to the root of the 2.0 install folder, so you'll see a list of all the folders, including bin, conf, etc. I don't remember what was there originally, but you now want to drag the openvpn.exe file into the root of the 2.0 folder. If it asks to replace, great, do so, and meet me on the next paragraph.
One thing . . . you want to make sure that the openvpn-gui.exe file is at the root of the 2.0 install as well. I think it's already there by default, but I don't remember.
Going on that assumption, the only thing that our script really needs to worry about is the addition of the following file:
libpkcs11-helper-1.dll
Add this line:
to the:
section so that it looks like this:
That takes care of problem2 if I remember correctly.
Now we need to add our .ovpn file and our .crt file to the install. Well *I* had to add the .crt file to the install. I'm not sure if you all will have to, that was just based on my config. To do that, follow the docs here:
http://openvpn.se/files/howto/openvpn-h ... ckage.html
One final thing. I had to comment out this line:
so it looked like this:
You may have to as well.
There is some extra cleanup code I added as well. I don't remember it all, so I'm going to show the contents of my .nsi file at the end of this post for reference.
Once you have everything the way you like it, find your openvpn-gui.nsi file, right-click on it, and choose "compile NSIS script". If all goes well, it will create an installer package for you. If THAT goes well, you'll be able to install it, and use it to your heart's content.
This is what I got to work. There's no guarantee that it will work for you in your circumstance, but you can get the gist of how I handled things. For instance, I don't think the service will start as it is now, but as it turns out that isn't a problem in my case. It may be in your case. YMMV! I hope I have provide enough for you to "run with" it. It is entirely likely that I got something above wrong. I had to mix/match/try so many different things that I doubt I got it 100% right. Post errors, and I hope I can help clean it up a bit.
openvpn-gui.nsi code:
This assumes you'll be doing all of this on a Windows machine, specifically in my case Windows 7.
Before you get started, make sure you install 7zip:
http://www.7-zip.org/download.html
Next download:
openvpn-2.2-beta5-install.exe
from http://swupdate.openvpn.net/community/r ... nstall.exe
Other versions MIGHT work, I don't know I haven't tested.
Next download: http://www.openvpn.se/files/install_pac ... beta26.zip
Again, other versions might work, but that's just the one that I used.
Finally download and install the NSIS install system here:
http://nsis.sourceforge.net/download
You'll be using this shortly but a little background.
The instructions here: http://openvpn.se/files/howto/openvpn-h ... ckage.html
presumably work for windows xp. I don't know I haven't tried it on XP, I'm using Windows 7. The problem with Windows 7 is that it expects the drivers to be made differently. The 2.2 installer (above) has a driver that Windows 7 likes (near as I can tell). I've been using it for testing quite a bit. The 2.0 Beta driver doesn't seem to work well, and I don't see any source for 2.2 available on any of the sites.
So what we have to do is steal guts from the 2.2 Beta install, and put them into the 2.0 install package. The only other option is to just create an install script of our own from scratch, and hope it works (which is too much work for me).
So that solves the problem with the driver but in my testing with the client, I was using directives that only 2.2 beta can recognize. When openvpn 2.0 beta tried to read the directives in the config file, it threw all sorts of errors. So we have to swap the guts of openvpn.exe, and it's various DLL files as well.
Note: I am using my install for a very specific purpose. I am using password auth on the server, so I don't have any clue if the openssl certificate stuff is behaving correctly in this install. Just a word of caution.
Get started by opening 7zip. In 7zip, browse to the location of where you downloaded your openvpn-2.2-beta5-install.exe. Right-click that file, choose 7zip, and "open archive". 7Zip will show you all the files in that installer now.
Cool huh?
So the first thing we want to accomplish is copying/replacing the files necessary to install the TAP interface. This guide does not deal with the hidden interface BTW. So in the 7zip archive window, double-click "driver". On my machine I saw 6 files there, 3 of which were dupes. Don't ask me why, I don't know, but I only dealt with the first three. So we have to put those files in the 2.0 installer source. So we unzip that installer, and make note of where it is. Then we open up the unzipped 2.0 installer. The first folder you should see in that unzipped archive is "openvpn". Double-click on that, and then you'll see a lot more folders. This is where all the "guts" of that installer is. Dive into tap-32, then i386. Now you want to drag the first three files from the 2.2 archive into this folder. 7zip will extract them, and copy them over to the i386 folder. If it asks you to replace, say "yes".
In the end there will be the following files:
OemWin2k.inf
tap0801.sys
tap0901.cat
tap0901.sys
There is another file involved in the installation of this driver, and to be honest I'm not even sure this step is necessary but I did it anyway.
In your 2.2 installer archive, go back up a folder to the root of the install. You do that by deleting "driver" in the address bar. That will take you back to the root of the install dir hopefully. A folder named "bin" is anxiously awaiting your arrival. Go there.
Notice there is a "tapinstall.exe" in there along with a number of other goodies. Pick one of the "tapinstall.exe" files (I honestly don't know which one. I see two when I'm looking at it). Drag one of them over to the "bin" folder in your 2.0 install source. I don't think there is one there by default, but if there is, say yes when it asks you to replace. Next double-click the "ti3790" folder, and drag the same tapinstall.exe from the 2.2 to that folder as well, and confirm replace.
So now we've taken care of PART of problem1. That's the TAP driver. To finish fixing this problem, we need to make changes to the installer code. So we need to get back to the top level of the install source files/folders. You'll see a script there called "openvpn-gui.nsi". Using notepad, open that puppy up. Now change the following lines:
Code: Select all
!define TAP "tap0801"
Code: Select all
!define TAP "tap0901"
Code: Select all
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${BIN}\ti3790\tapinstall.exe"
The silly thing is that I think the ti3790 isn't even necessary because it doesn't even show up on my computer after it is installed. Again this is what worked for me. I encourage people brighter and more patient than I am to clean this up and make it more clear. The essential bit is above though okay? Make sure that's in the installer code, and save that code but don't close it out. We'll need it again several more times.
So we've now fixed Problem1, which is the tap driver (in theory). Now when this installs, it will give you warnings about unsigned drivers, and it will also give you a compatibility warning too. Just click to not show the warnings again, and choose run. It will work. Actually you may not even see that warning at all, I don't know. I did, but I horsed around a lot with these installers, so some of their junk could have interfered.
Problem2
This may not even be a problem for you but it was for me. The .ovbn file I created has directives compatible with the 2.2 version of the openvpn.exe. So I had to replace those files as well. If your syntax is 2.0 compatible, you can likely totally skip this part. I'm not 100% sure of that but I believe that's the case.
So what we have to do now is find the related items from the 2.2 installer, and just like in problem1, copy them over, and replace files as necessary. Then modify the installer script so that it knows what's up. Sound good?
So head on over to the 2.2 archive window. We want to make sure we're in the installer's "bin" directory. If you're not already there, please get there.
Next find the "bin" directory in the 2.0 install, and have that open and available. Now drag the following files from 2.2 to the 2.0 install source bin folder.
libeay32.dll
libpkcs22-helper-1.dll
libssl32.dll
Make sure you replace what's in the 2.0 bin dir with those files.
Next we want to copy over the openvpn.exe file. That file goes in the root of the install dir. Why that works as opposed to being in the BIN dir I don't know. As a matter of fact, it probably WOULD work in the bin folder but the install script likes it in the root of the install folder as you'll see shortly. So navigate to the root of the 2.0 install folder, so you'll see a list of all the folders, including bin, conf, etc. I don't remember what was there originally, but you now want to drag the openvpn.exe file into the root of the 2.0 folder. If it asks to replace, great, do so, and meet me on the next paragraph.
One thing . . . you want to make sure that the openvpn-gui.exe file is at the root of the 2.0 install as well. I think it's already there by default, but I don't remember.
Going on that assumption, the only thing that our script really needs to worry about is the addition of the following file:
libpkcs11-helper-1.dll
Add this line:
Code: Select all
File "${BIN}\libpkcs11-helper-1.dll"
Code: Select all
Section "OpenSSL DLLs" SecOpenSSLDLLs
Code: Select all
Section "OpenSSL DLLs" SecOpenSSLDLLs
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${BIN}\libeay32.dll"
File "${BIN}\libssl32.dll"
File "${BIN}\libpkcs11-helper-1.dll"
SectionEnd
Now we need to add our .ovpn file and our .crt file to the install. Well *I* had to add the .crt file to the install. I'm not sure if you all will have to, that was just based on my config. To do that, follow the docs here:
http://openvpn.se/files/howto/openvpn-h ... ckage.html
One final thing. I had to comment out this line:
Code: Select all
!insertmacro MUI_LANGUAGE "English"
Code: Select all
; !insertmacro MUI_LANGUAGE "English"
There is some extra cleanup code I added as well. I don't remember it all, so I'm going to show the contents of my .nsi file at the end of this post for reference.
Once you have everything the way you like it, find your openvpn-gui.nsi file, right-click on it, and choose "compile NSIS script". If all goes well, it will create an installer package for you. If THAT goes well, you'll be able to install it, and use it to your heart's content.
This is what I got to work. There's no guarantee that it will work for you in your circumstance, but you can get the gist of how I handled things. For instance, I don't think the service will start as it is now, but as it turns out that isn't a problem in my case. It may be in your case. YMMV! I hope I have provide enough for you to "run with" it. It is entirely likely that I got something above wrong. I had to mix/match/try so many different things that I doubt I got it 100% right. Post errors, and I hope I can help clean it up a bit.
openvpn-gui.nsi code:
Code: Select all
; ****************************************************************************
; * COPYRIGHT (C) 2003-2004 James Yonan *
; * This program is free software; you can redistribute it and/or modify *
; * it under the terms of the GNU General Public License as published by *
; * the Free Software Foundation; either version 2 of the License, or *
; * (at your option) any later version. *
; ****************************************************************************
; OpenVPN install script for Windows, using NSIS
!include "MUI.nsh"
!include "setpath.nsi"
!define MASTER "x:\openvpn\exp\openvpn"
!define HOME "openvpn"
!define BIN "${HOME}\bin"
!define MUI_PRODUCT "OpenVPN"
!define OPENVPN_VERSION "2.0_beta19"
!define GUI_VERSION "1.0-beta26"
!define MYCERT_VERSION "0.3.2b"
!define MUI_VERSION "${OPENVPN_VERSION}-gui-${GUI_VERSION}"
!define TAP "tap0901"
!define TAPDRV "${TAP}.sys"
; something like "-DBG2"
!define OUTFILE_LABEL ""
; something like "DEBUG2"
!define TITLE_LABEL ""
; Default OpenVPN Service registry settings
!define SERV_CONFIG_DIR "$INSTDIR\config"
!define SERV_CONFIG_EXT "ovpn"
!define SERV_EXE_PATH "$INSTDIR\bin\openvpn.exe"
!define SERV_LOG_DIR "$INSTDIR\log"
!define SERV_PRIORITY "NORMAL_PRIORITY_CLASS"
!define SERV_LOG_APPEND "0"
; Default OpenVPN GUI registry settings
!define GUI_CONFIG_DIR "$INSTDIR\config"
!define GUI_CONFIG_EXT "ovpn"
!define GUI_EXE_PATH "$INSTDIR\bin\openvpn.exe"
!define GUI_LOG_DIR "$INSTDIR\log"
!define GUI_PRIORITY "NORMAL_PRIORITY_CLASS"
!define GUI_LOG_APPEND "0"
!define GUI_ALLOW_EDIT "1"
!define GUI_ALLOW_SERVICE "0"
!define GUI_ALLOW_PROXY "1"
!define GUI_PSW_ATTEMPTS "3"
!define GUI_UP_TIMEOUT "15"
!define GUI_LOG_VIEWER "$WINDIR\notepad.exe"
!define GUI_EDITOR "$WINDIR\notepad.exe"
!define GUI_SUSPEND "1"
!define GUI_SILENT_CONN "0"
;--------------------------------
;Configuration
;General
OutFile "openvpn-${MUI_VERSION}${OUTFILE_LABEL}-install.exe"
SetCompressor bzip2
ShowInstDetails show
ShowUninstDetails show
;Folder selection page
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}"
;Remember install folder
InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" ""
!define SOURCE_ZIP_DEST "openvpn-${OPENVPN_VERSION}.zip"
!define SOURCE_ZIP_SRC "${HOME}\${SOURCE_ZIP_DEST}"
!define GUI_SOURCE_ZIP_DEST "openvpn-gui-${GUI_VERSION}.zip"
!define GUI_SOURCE_ZIP_SRC "${HOME}\${GUI_SOURCE_ZIP_DEST}"
!define MYCERT_SOURCE_ZIP_DEST "mycert-src-${MYCERT_VERSION}.zip"
!define MYCERT_SOURCE_ZIP_SRC "${HOME}\mycertwizard\${MYCERT_SOURCE_ZIP_DEST}"
# For testing only
#!define SOURCE_ZIP_SRC "c:\src\openvpn\install-win32\null.zip"
;--------------------------------
;Modern UI Configuration
!define MUI_NAME "${MUI_PRODUCT} ${MUI_VERSION} ${TITLE_LABEL}"
!define MUI_WELCOMEPAGE
!define MUI_LICENSEPAGE
!define MUI_COMPONENTSPAGE
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_DIRECTORYPAGE
!define MUI_FINISHPAGE
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\INSTALL-win32.txt"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_ABORTWARNING
!define MUI_UNINSTALLER
!define MUI_UNCONFIRMPAGE
!define MUI_ICON "${HOME}\install-win32\openvpn.ico"
!define MUI_UNICON "${HOME}\install-win32\openvpn.ico"
!define MUI_HEADERBITMAP "${HOME}\install-win32\install-whirl.bmp"
;--------------------------------
;Languages
!define MUI_TEXT_WELCOME_INFO_TEXT "This wizard will guide you through the installation of:\r\n\r\nOpenVPN - an Open Source VPN package by James Yonan.\r\n\r\nOpenVPN GUI - A Graphical User Interface for OpenVPN by Mathias Sundman\r\n\r\nMy Certificate Wizard - A tool to create a certificate request by Vlada Macek\r\n\r\nNote that the Windows version of OpenVPN will only run on Win 2000, XP, or higher.\r\n\r\n\r\n"
!define MUI_INNERTEXT_COMPONENTS_TOP "Select the components to install/upgrade. Stop any OpenVPN or OpenVPN GUI processes or the OpenVPN service if it is running."
; !insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Language Strings
LangString DESC_SecOpenVPNUserSpace ${LANG_ENGLISH} "Install OpenVPN user-space components, including openvpn.exe."
LangString DESC_SecOpenSSLDLLs ${LANG_ENGLISH} "Install OpenSSL DLLs locally (may be omitted if DLLs are already installed globally)."
LangString DESC_SecTAP ${LANG_ENGLISH} "Install/Upgrade the TAP-Win32 virtual device driver. Will not interfere with CIPE."
LangString DESC_SecTAPHidden ${LANG_ENGLISH} "Install the TAP device as hidden. The TAP device will not be visible under Network Connections."
LangString DESC_SecService ${LANG_ENGLISH} "Install the OpenVPN service wrapper (openvpnserv.exe)"
LangString DESC_SecOpenSSLUtilities ${LANG_ENGLISH} "Install the OpenSSL Utilities (used for generating public/private key pairs)."
LangString DESC_SecOpenVPNSource ${LANG_ENGLISH} "Install (but do not unzip) the source code zip files."
LangString DESC_SecAddPath ${LANG_ENGLISH} "Add OpenVPN executable directory to the current user's PATH."
LangString DESC_SecAddShortcuts ${LANG_ENGLISH} "Add shortcuts to the current user's Start Menu."
LangString DESC_SecFileAssociation ${LANG_ENGLISH} "Register OpenVPN config file association (*.${SERV_CONFIG_EXT})"
LangString DESC_SecGUI ${LANG_ENGLISH} "Install OpenVPN GUI (A System tray application to control OpenVPN)"
LangString DESC_SecGUIAuto ${LANG_ENGLISH} "Automatically start OpenVPN GUI at system startup"
LangString DESC_SecMYCERT ${LANG_ENGLISH} "Install My Certificate Wizard - A tool to create a certificate request."
;--------------------------------
;Data
LicenseData "${HOME}\install-win32\license.txt"
;--------------------------------
;Reserve Files
;Things that need to be extracted on first (keep these lines before any File command!)
;Only useful for BZIP2 compression
ReserveFile "${HOME}\install-win32\install-whirl.bmp"
;--------------------------------
;Macros
!macro WriteRegStringIfUndef ROOT SUBKEY KEY VALUE
Push $R0
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
StrCmp $R0 "" +1 +2
WriteRegStr "${ROOT}" "${SUBKEY}" "${KEY}" '${VALUE}'
Pop $R0
!macroend
!macro DelRegStringIfUnchanged ROOT SUBKEY KEY VALUE
Push $R0
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" "${KEY}"
StrCmp $R0 '${VALUE}' +1 +2
DeleteRegValue "${ROOT}" "${SUBKEY}" "${KEY}"
Pop $R0
!macroend
!macro DelRegKeyIfUnchanged ROOT SUBKEY VALUE
Push $R0
ReadRegStr $R0 "${ROOT}" "${SUBKEY}" ""
StrCmp $R0 '${VALUE}' +1 +2
DeleteRegKey "${ROOT}" "${SUBKEY}"
Pop $R0
!macroend
!macro DelRegKeyIfEmpty ROOT SUBKEY
Push $R0
EnumRegValue $R0 "${ROOT}" "${SUBKEY}" 1
StrCmp $R0 "" +1 +2
DeleteRegKey /ifempty "${ROOT}" "${SUBKEY}"
Pop $R0
!macroend
;------------------------------------------
;Set reboot flag based on tapinstall return
Function CheckReboot
IntCmp $R0 1 "" noreboot noreboot
IntOp $R0 0 & 0
SetRebootFlag true
DetailPrint "REBOOT flag set"
noreboot:
FunctionEnd
;--------------------------------
;Installer Sections
!define SF_SELECTED 1
!define SF_RO 16
!define SF_NOT_RO 0xFFFFFFEF
Section "OpenVPN User-Space Components" SecOpenVPNUserSpace
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${HOME}\openvpn.exe"
SectionEnd
Section "OpenVPN GUI" SecGUI
; SetOverwrite on
; SetOutPath "$INSTDIR\bin"
; File "${HOME}\openvpn-gui.exe"
SetOverwrite on
SetOutPath "$INSTDIR\"
File "${HOME}\openvpn-gui.exe"
SetOutPath "$INSTDIR\config"
File "${HOME}\config\sample.${SERV_CONFIG_EXT}.txt"
File "${HOME}\config\client.ovpn"
CreateDirectory "$INSTDIR\log"
SectionEnd
Section "AutoStart OpenVPN GUI" SecGUIAuto
SectionEnd
Section "My Certificate Wizard" SecMYCERT
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${HOME}\mycertwizard\mycert.exe"
File "${HOME}\mycertwizard\mycert.ini"
SectionEnd
Section "Hide the TAP-Win32 Virtual Ethernet Adapter" SecTAPHidden
SectionEnd
Section "OpenVPN Service" SecService
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${HOME}\service-win32\openvpnserv.exe"
FileOpen $R0 "$INSTDIR\config\README.txt" w
FileWrite $R0 "This directory should contain OpenVPN configuration files$\r$\n"
FileWrite $R0 "each having an extension of .${SERV_CONFIG_EXT}$\r$\n"
FileWrite $R0 "$\r$\n"
FileWrite $R0 "When OpenVPN is started as a service, a separate OpenVPN$\r$\n"
FileWrite $R0 "process will be instantiated for each configuration file.$\r$\n"
FileClose $R0
CreateDirectory "$INSTDIR\log"
FileOpen $R0 "$INSTDIR\log\README.txt" w
FileWrite $R0 "This directory will contain the log files for OpenVPN$\r$\n"
FileWrite $R0 "sessions which are being run as a service.$\r$\n"
FileClose $R0
SectionEnd
Section "OpenVPN File Associations" SecFileAssociation
SectionEnd
Section "OpenSSL DLLs" SecOpenSSLDLLs
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${BIN}\libeay32.dll"
File "${BIN}\libssl32.dll"
File "${BIN}\libpkcs11-helper-1.dll"
SectionEnd
Section "OpenSSL Utilities" SecOpenSSLUtilities
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${BIN}\openssl.exe"
SectionEnd
Section "TAP-Win32 Virtual Ethernet Adapter" SecTAP
SetOverwrite on
SetOutPath "$INSTDIR\bin"
File "${BIN}\ti3790\tapinstall.exe"
FileOpen $R0 "$INSTDIR\bin\addtap.bat" w
FileWrite $R0 "rem Add a new TAP-Win32 virtual ethernet adapter$\r$\n"
FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}$\r$\n'
FileWrite $R0 "pause$\r$\n"
FileClose $R0
FileOpen $R0 "$INSTDIR\bin\deltapall.bat" w
FileWrite $R0 "echo WARNING: this script will delete ALL TAP-Win32 virtual adapters (use the device manager to delete adapters one at a time)$\r$\n"
FileWrite $R0 "pause$\r$\n"
FileWrite $R0 '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}$\r$\n'
FileWrite $R0 "pause$\r$\n"
FileClose $R0
SetOutPath "$INSTDIR\driver"
File "${HOME}\tap-win32\i386\${TAPDRV}"
SectionGetFlags ${SecTAPHidden} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nohiddentap nohiddentap
File "${HOME}\tap-win32-hiddentap\i386\OemWin2k.inf"
goto end
nohiddentap:
File "${HOME}\tap-win32\i386\OemWin2k.inf"
end:
SectionEnd
Section "Add OpenVPN to PATH" SecAddPath
; remove previously set path (if any)
Push "$INSTDIR\bin"
Call RemoveFromPath
; append our bin directory to end of current user path
Push "$INSTDIR\bin"
Call AddToPath
SectionEnd
Section "Add Shortcuts to Start Menu" SecAddShortcuts
SetOverwrite on
CreateDirectory "$SMPROGRAMS\OpenVPN"
CreateShortCut "$SMPROGRAMS\OpenVPN\OpenVPN Win32 README.lnk" "$INSTDIR\INSTALL-win32.txt" ""
WriteINIStr "$SMPROGRAMS\OpenVPN\OpenVPN Manual Page.url" "InternetShortcut" "URL" "http://openvpn.sourceforge.net/man.html"
WriteINIStr "$SMPROGRAMS\OpenVPN\OpenVPN Web Site.url" "InternetShortcut" "URL" "http://openvpn.sourceforge.net/"
CreateShortCut "$SMPROGRAMS\OpenVPN\Uninstall OpenVPN.lnk" "$INSTDIR\Uninstall.exe"
SectionGetFlags ${SecGUI} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nogui nogui
CreateShortCut "$SMPROGRAMS\OpenVPN\OpenVPN GUI.lnk" "$INSTDIR\openvpn-gui.exe"
nogui:
SectionGetFlags ${SecMYCERT} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nomycert nomycert
CreateShortCut "$SMPROGRAMS\OpenVPN\My Certificate Wizard.lnk" "$INSTDIR\bin\mycert.exe"
nomycert:
SectionEnd
Section "Source Code" SecOpenVPNSource
SetOverwrite on
SetOutPath "$INSTDIR"
File "${HOME}\ca.crt"
File "${SOURCE_ZIP_SRC}"
SectionGetFlags ${SecGUI} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nogui nogui
File "${GUI_SOURCE_ZIP_SRC}"
nogui:
SectionGetFlags ${SecMYCERT} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nomycert nomycert
File "${MYCERT_SOURCE_ZIP_SRC}"
nomycert:
SectionEnd
;--------------------
;Post-install section
Section -post
; delete old devcon.exe
Delete "$INSTDIR\bin\devcon.exe"
;
; install/upgrade TAP-Win32 driver if selected, using tapinstall.exe
;
SectionGetFlags ${SecTAP} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" notap notap
; TAP install/update was selected.
; Should we install or update?
; If tapinstall error occurred, $5 will
; be nonzero.
IntOp $5 0 & 0
nsExec::ExecToStack '"$INSTDIR\bin\tapinstall.exe" hwids ${TAP}'
Pop $R0 # return value/error/timeout
IntOp $5 $5 | $R0
DetailPrint "tapinstall hwids returned: $R0"
; If tapinstall output string contains "${TAP}" we assume
; that TAP device has been previously installed,
; therefore we will update, not install.
Push "${TAP}"
Call StrStr
Pop $R0
IntCmp $5 0 "" tapinstall_check_error tapinstall_check_error
IntCmp $R0 -1 tapinstall
;tapupdate:
DetailPrint "TAP-Win32 UPDATE"
nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" update "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
Pop $R0 # return value/error/timeout
Call CheckReboot
IntOp $5 $5 | $R0
DetailPrint "tapinstall update returned: $R0"
Goto tapinstall_check_error
tapinstall:
DetailPrint "TAP-Win32 REMOVE OLD TAP"
nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAP'
Pop $R0 # return value/error/timeout
DetailPrint "tapinstall remove TAP returned: $R0"
nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove TAPDEV'
Pop $R0 # return value/error/timeout
DetailPrint "tapinstall remove TAPDEV returned: $R0"
DetailPrint "TAP-Win32 INSTALL (${TAP})"
nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" install "$INSTDIR\driver\OemWin2k.inf" ${TAP}'
Pop $R0 # return value/error/timeout
Call CheckReboot
IntOp $5 $5 | $R0
DetailPrint "tapinstall install returned: $R0"
tapinstall_check_error:
DetailPrint "tapinstall cumulative status: $5"
IntCmp $5 0 notap
MessageBox MB_OK "An error occurred installing the TAP-Win32 device driver."
notap:
; Store install folder in registry
WriteRegStr HKLM SOFTWARE\OpenVPN "" $INSTDIR
; install as a service if requested
SectionGetFlags ${SecService} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" noserv noserv
; set registry parameters for openvpnserv
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "config_dir" "${SERV_CONFIG_DIR}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "config_ext" "${SERV_CONFIG_EXT}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "exe_path" "${SERV_EXE_PATH}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "log_dir" "${SERV_LOG_DIR}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "priority" "${SERV_PRIORITY}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN" "log_append" "${SERV_LOG_APPEND}"
; install openvpnserv as a service
DetailPrint "Previous Service REMOVE (if exists)"
nsExec::ExecToLog '"$INSTDIR\bin\openvpnserv.exe" -remove'
Pop $R0 # return value/error/timeout
DetailPrint "Service INSTALL"
nsExec::ExecToLog '"$INSTDIR\bin\openvpnserv.exe" -install'
Pop $R0 # return value/error/timeout
noserv:
; Store install folder in registry
WriteRegStr HKLM SOFTWARE\OpenVPN-GUI "" $INSTDIR
; Set registry keys for openvpn-gui if gui is requested
SectionGetFlags ${SecGUI} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nogui nogui
; set registry parameters for openvpn-gui
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "config_dir" "${GUI_CONFIG_DIR}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "config_ext" "${GUI_CONFIG_EXT}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "exe_path" "${GUI_EXE_PATH}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "log_dir" "${GUI_LOG_DIR}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "priority" "${GUI_PRIORITY}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "log_append" "${GUI_LOG_APPEND}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "allow_edit" "${GUI_ALLOW_EDIT}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "allow_service" "${GUI_ALLOW_SERVICE}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "allow_proxy" "${GUI_ALLOW_PROXY}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "log_viewer" "${GUI_LOG_VIEWER}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "passphrase_attempts" "${GUI_PSW_ATTEMPTS}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "editor" "${GUI_EDITOR}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "connectscript_timeout" "${GUI_UP_TIMEOUT}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "silent_connection" "${GUI_SILENT_CONN}"
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\OpenVPN-GUI" "disconnect_on_suspend" "${GUI_SUSPEND}"
; AutoStart OpenVPN GUI if requested
SectionGetFlags ${SecGUIAuto} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" nogui nogui
; set registry parameters for openvpn-gui
!insertmacro WriteRegStringIfUndef HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "openvpn-gui" "$INSTDIR\bin\openvpn-gui.exe"
nogui:
; Store README, license, icon
SetOverwrite on
SetOutPath $INSTDIR
File "${HOME}\install-win32\INSTALL-win32.txt"
File "${HOME}\install-win32\license.txt"
File "${HOME}\install-win32\openvpn.ico"
; Create file association if requested
SectionGetFlags ${SecFileAssociation} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 ${SF_SELECTED} "" noass noass
!insertmacro WriteRegStringIfUndef HKCR ".${SERV_CONFIG_EXT}" "" "OpenVPNFile"
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile" "" "OpenVPN Config File"
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile\shell" "" "open"
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile\DefaultIcon" "" "$INSTDIR\openvpn.ico,0"
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile\shell\open\command" "" 'notepad.exe "%1"'
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile\shell\run" "" "Start OpenVPN on this config file"
!insertmacro WriteRegStringIfUndef HKCR "OpenVPNFile\shell\run\command" "" '"$INSTDIR\bin\openvpn.exe" --pause-exit --config "%1"'
noass:
; Create start menu link to source distribution zip file
IfFileExists "$SMPROGRAMS\OpenVPN" "" noshortcuts
IfFileExists "$INSTDIR\${SOURCE_ZIP_DEST}" "" nosourcezip
CreateShortCut "$SMPROGRAMS\OpenVPN\OpenVPN Source Code Distribution.lnk" "$INSTDIR\${SOURCE_ZIP_DEST}" ""
; Create start menu shortcuts to addtap.bat and deltapall.bat
nosourcezip:
IfFileExists "$INSTDIR\bin\addtap.bat" "" trydeltap
CreateShortCut "$SMPROGRAMS\OpenVPN\Add a new TAP-Win32 virtual ethernet adapter.lnk" "$INSTDIR\bin\addtap.bat" ""
trydeltap:
IfFileExists "$INSTDIR\bin\deltapall.bat" "" config_shortcut
CreateShortCut "$SMPROGRAMS\OpenVPN\Delete ALL TAP-Win32 virtual ethernet adapters.lnk" "$INSTDIR\bin\deltapall.bat" ""
; Create start menu shortcuts for config and log directories
config_shortcut:
IfFileExists "$INSTDIR\config" "" log_shortcut
CreateShortCut "$SMPROGRAMS\OpenVPN\OpenVPN configuration file directory.lnk" "$INSTDIR\config" ""
log_shortcut:
IfFileExists "$INSTDIR\log" "" genkey_shortcut
CreateShortCut "$SMPROGRAMS\OpenVPN\OpenVPN log file directory.lnk" "$INSTDIR\log" ""
genkey_shortcut:
IfFileExists "$INSTDIR\bin\openvpn.exe" "" noshortcuts
IfFileExists "$INSTDIR\config" "" noshortcuts
CreateShortCut "$SMPROGRAMS\OpenVPN\Generate a static OpenVPN key.lnk" "$INSTDIR\bin\openvpn.exe" '--pause-exit --verb 3 --genkey --secret "$INSTDIR\config\key.txt"' "$INSTDIR\openvpn.ico" 0
noshortcuts:
; Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
; Show up in Add/Remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVPN" "DisplayName" "OpenVPN ${MUI_VERSION}"
WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVPN" "UninstallString" "$INSTDIR\Uninstall.exe"
; Advise a reboot
;Messagebox MB_OK "IMPORTANT: Rebooting the system is advised in order to finalize TAP-Win32 driver installation/upgrade (this is an informational message only, pressing OK will not reboot)."
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayIcon" "$INSTDIR\openvpn.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MUI_PRODUCT}" "DisplayVersion" "${MUI_VERSION}"
SectionEnd
;Display the Finish header
;Insert this macro after the sections if you are not using a finish page
;!insertmacro MUI_SECTIONS_FINISHHEADER
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNUserSpace} $(DESC_SecOpenVPNUserSpace)
!insertmacro MUI_DESCRIPTION_TEXT ${SecGUI} $(DESC_SecGUI)
!insertmacro MUI_DESCRIPTION_TEXT ${SecGUIAuto} $(DESC_SecGUIAuto)
!insertmacro MUI_DESCRIPTION_TEXT ${SecMYCERT} $(DESC_SecMYCERT)
!insertmacro MUI_DESCRIPTION_TEXT ${SecTAP} $(DESC_SecTAP)
!insertmacro MUI_DESCRIPTION_TEXT ${SecTAPHidden} $(DESC_SecTAPHidden)
!insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLUtilities} $(DESC_SecOpenSSLUtilities)
!insertmacro MUI_DESCRIPTION_TEXT ${SecOpenSSLDLLs} $(DESC_SecOpenSSLDLLs)
!insertmacro MUI_DESCRIPTION_TEXT ${SecOpenVPNSource} $(DESC_SecOpenVPNSource)
!insertmacro MUI_DESCRIPTION_TEXT ${SecAddPath} $(DESC_SecAddPath)
!insertmacro MUI_DESCRIPTION_TEXT ${SecAddShortcuts} $(DESC_SecAddShortcuts)
!insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
!insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} $(DESC_SecFileAssociation)
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END
Function .onInit
ClearErrors
UserInfo::GetName
IfErrors ok
Pop $R0
UserInfo::GetAccountType
Pop $R1
StrCmp $R1 "Admin" ok
Messagebox MB_OK "Administrator privileges required to install OpenVPN [$R0/$R1]"
Abort
ok:
Push $R0
ReadRegStr $R0 HKLM SOFTWARE\OpenVPN-GUI ""
StrCmp $R0 "" goon
Messagebox MB_YESNO "It seems the package ${MUI_PRODUCT} (OpenVPN GUI) is already installed.$\r$\nWe recommend you to uninstall it in the standard way before proceeding. Continue installing?" IDYES goon
Abort
goon:
Pop $R0
Push $R0
Push $R1
FindWindow $R0 "openvpn-gui"
IntCmp $R0 0 donerun
Messagebox MB_YESNO|MB_ICONEXCLAMATION "OpenVPN GUI is currently running.$\r$\nUntil you terminate it, all files that belong to it cannot be updated.$\r$\nShall this program be killed now? If true, all existing connections will be closed." IDNO donerun
SendMessage $R0 ${WM_DESTROY} 0 0 $R1 /TIMEOUT=7000
IntCmp $R1 0 donerun
Messagebox MB_OK|MB_ICONEXCLAMATION "Trouble terminating OpenVPN GUI, please close it and then click OK."
donerun:
Pop $R1
Pop $R0
;Disable My Certificate Wizard as default.
SectionSetFlags ${SecMYCERT} 0
; Don't install the TAP driver as hiddden as default.
SectionSetFlags ${SecTAPHidden} 0
FunctionEnd
Function .onSelChange
Push $0
;Check if Section OpenVPN GUI is selected.
SectionGetFlags ${SecGUI} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} "" noautogui noautogui
;GUI was selected so set GUIAuto to Not-ReadOnly.
SectionGetFlags ${SecGUIAuto} $0
IntOp $0 $0 & ${SF_NOT_RO}
SectionSetFlags ${SecGUIAuto} $0
goto CheckTAP
noautogui:
SectionSetFlags ${SecGUIAuto} ${SF_RO}
CheckTAP:
;Check if Section Install-TAP is selected.
SectionGetFlags ${SecTAP} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} "" notap notap
;TAP was selected so set TAPHidden to Not-ReadOnly.
SectionGetFlags ${SecTAPHidden} $0
IntOp $0 $0 & ${SF_NOT_RO}
SectionSetFlags ${SecTAPHidden} $0
goto end
notap:
SectionSetFlags ${SecTAPHidden} ${SF_RO}
end:
Pop $0
FunctionEnd
Function .onInstSuccess
IfFileExists "$INSTDIR\bin\openvpn-gui.exe" "" nogui
ExecShell open "$INSTDIR\bin\openvpn-gui.exe"
nogui:
FunctionEnd
;--------------------------------
;Uninstaller Section
Function un.onInit
ClearErrors
UserInfo::GetName
IfErrors ok
Pop $R0
UserInfo::GetAccountType
Pop $R1
StrCmp $R1 "Admin" ok
Messagebox MB_OK "Administrator privileges required to uninstall OpenVPN [$R0/$R1]"
Abort
ok:
Push $R0
Push $R1
FindWindow $R0 "openvpn-gui"
IntCmp $R0 0 donerun
Messagebox MB_YESNO|MB_ICONEXCLAMATION "OpenVPN GUI is currently running.$\r$\nUntil you terminate it, all files that belong to it cannot be removed.$\r$\nShall this program be killed now? If true, all existing connections will be closed." IDNO donerun
SendMessage $R0 ${WM_DESTROY} 0 0 $R1 /TIMEOUT=7000
IntCmp $R1 0 donerun
Messagebox MB_OK|MB_ICONEXCLAMATION "Trouble terminating OpenVPN GUI, please close it and then click OK."
donerun:
Pop $R1
Pop $R0
FunctionEnd
Section "Uninstall"
DetailPrint "Service REMOVE"
nsExec::ExecToLog '"$INSTDIR\bin\openvpnserv.exe" -remove'
Pop $R0 # return value/error/timeout
Sleep 2000
DetailPrint "TAP-Win32 REMOVE"
nsExec::ExecToLog '"$INSTDIR\bin\tapinstall.exe" remove ${TAP}'
Pop $R0 # return value/error/timeout
DetailPrint "tapinstall remove returned: $R0"
Push "$INSTDIR\bin"
Call un.RemoveFromPath
RMDir /r $SMPROGRAMS\OpenVPN
Delete "$INSTDIR\bin\openvpn.exe"
Delete "$INSTDIR\bin\openvpnserv.exe"
Delete "$INSTDIR\bin\openvpn-gui.exe"
Delete "$INSTDIR\bin\libeay32.dll"
Delete "$INSTDIR\bin\libpkcs11-helper-1.dll"
Delete "$INSTDIR\bin\libssl32.dll"
Delete "$INSTDIR\bin\tapinstall.exe"
Delete "$INSTDIR\bin\addtap.bat"
Delete "$INSTDIR\bin\deltapall.bat"
Delete "$INSTDIR\bin\mycert.exe"
Delete "$INSTDIR\bin\mycert.ini"
Delete "$INSTDIR\config\README.txt"
Delete "$INSTDIR\config\sample.${SERV_CONFIG_EXT}.txt"
Delete "$INSTDIR\config\client.ovpn"
Delete "$INSTDIR\log\README.txt"
Delete "$INSTDIR\driver\OemWin2k.inf"
Delete "$INSTDIR\driver\${TAPDRV}"
Delete "$INSTDIR\bin\openssl.exe"
Delete "$INSTDIR\${SOURCE_ZIP_DEST}"
Delete "$INSTDIR\${GUI_SOURCE_ZIP_DEST}"
Delete "$INSTDIR\${MYCERT_SOURCE_ZIP_DEST}"
Delete "$INSTDIR\INSTALL-win32.txt"
Delete "$INSTDIR\ca.crt"
Delete "$INSTDIR\openvpn-gui.exe"
Delete "$INSTDIR\openvpn.ico"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\Uninstall.exe"
RMDir "$INSTDIR\bin"
RMDir "$INSTDIR\driver"
RMDir "$INSTDIR\log"
RMDir "$INSTDIR\config"
RMDir "$INSTDIR"
!insertmacro DelRegKeyIfUnchanged HKCR ".${SERV_CONFIG_EXT}" "OpenVPNFile"
DeleteRegKey HKCR "OpenVPNFile"
DeleteRegKey HKLM SOFTWARE\OpenVPN
DeleteRegKey HKLM SOFTWARE\OpenVPN-GUI
DeleteRegKey HKCU "Software\${MUI_PRODUCT}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenVPN"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "openvpn-gui"
;Messagebox MB_OK "IMPORTANT: If you intend on reinstalling OpenVPN after this uninstall, and you are running Win2K, you are strongly urged to reboot before reinstalling (this is an informational message only, pressing OK will not reboot)."
;Display the Finish header
;!insertmacro MUI_UNFINISHHEADER
SectionEnd
-
- OpenVpn Newbie
- Posts: 12
- Joined: Sun Feb 27, 2011 3:18 pm
Re: Win7
There are problems with this code BTW. A driver file is not being copied over correctly, and the choice of files to copy over is VERY important depending on whether the installer is 32 or 64 bit compatible. I'll try to update soon.