diff --git a/win32/Make.rules.mak b/win32/Make.rules.mak
index d7a1ae04..6a44bb77 100644
--- a/win32/Make.rules.mak
+++ b/win32/Make.rules.mak
@@ -1,4 +1,3 @@
-
OPENSC_FEATURES = pcsc
#Uncomment to use 'static' linking mode
@@ -7,16 +6,15 @@ LINK_MODE = STATIC
#Include support of minidriver 'cardmod'
MINIDRIVER_DEF = /DENABLE_CARDMOD
-
#Build MSI with the Windows Installer XML (WIX), minimal WIX version 3.6
+WIX_INSTALLED_PATH = "C:\Program Files\Windows Installer XML v3.6"
+
#Static link mode should be used.
#WIX_MSI_DEF = /DBUILD_MSI
!IF "$(WIX_MSI_DEF)" == "/DBUILD_MSI"
-WIX_INSTALLED_PATH = c:\download\wix36-binaries
LINK_MODE = STATIC
!ENDIF
-
# If you want support for OpenSSL (needed for pkcs15-init tool, software hashing in PKCS#11 library and verification):
# - download and build OpenSSL
# - uncomment the line starting with OPENSSL_DEF
diff --git a/win32/Makefile.mak b/win32/Makefile.mak
index fbfe876a..f26c570d 100644
--- a/win32/Makefile.mak
+++ b/win32/Makefile.mak
@@ -1,9 +1,17 @@
+TOPDIR = ..
+
+!INCLUDE $(TOPDIR)\win32\Make.rules.mak
all: config.h
config.h: winconfig.h
@copy /y winconfig.h config.h
-clean::
- del /Q config.h
+OpenSC.msi: OpenSC.wixobj
+ $(WIX_INSTALLED_PATH)\bin\light.exe -sh -ext WixUIExtension $?
+OpenSC.wixobj: OpenSC.wxs
+ $(WIX_INSTALLED_PATH)\bin\candle.exe -dSOURCE_DIR=$(TOPDIR) $?
+
+clean::
+ del /Q config.h *.msi *.wixobj *.wixpdb
diff --git a/win32/opensc-msi/OpenSC.ico b/win32/OpenSC.ico
similarity index 100%
rename from win32/opensc-msi/OpenSC.ico
rename to win32/OpenSC.ico
diff --git a/win32/OpenSC.wxs b/win32/OpenSC.wxs
new file mode 100644
index 00000000..6826be4a
--- /dev/null
+++ b/win32/OpenSC.wxs
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/win32/opensc-msi/OpenSC.wxs b/win32/opensc-msi/OpenSC.wxs
deleted file mode 100755
index d6c86e1e..00000000
--- a/win32/opensc-msi/OpenSC.wxs
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-