diff --git a/dokan_control/dokan_control.vcxproj b/dokan_control/dokan_control.vcxproj
index e050817f8..cf237fa84 100644
--- a/dokan_control/dokan_control.vcxproj
+++ b/dokan_control/dokan_control.vcxproj
@@ -174,6 +174,7 @@
true
RequireAdministrator
../debug
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -190,6 +191,7 @@
true
RequireAdministrator
../debug
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -206,6 +208,7 @@
true
RequireAdministrator
../debug
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -222,6 +225,7 @@
true
RequireAdministrator
../debug
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -239,6 +243,7 @@
true
true
RequireAdministrator
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -256,6 +261,7 @@
true
true
RequireAdministrator
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -273,6 +279,7 @@
true
true
RequireAdministrator
+ Shlwapi.lib;%(AdditionalDependencies)
@@ -290,6 +297,7 @@
true
true
RequireAdministrator
+ Shlwapi.lib;%(AdditionalDependencies)
diff --git a/dokan_control/dokanctl.c b/dokan_control/dokanctl.c
index 4e3d9ee1f..43bd7a47d 100644
--- a/dokan_control/dokanctl.c
+++ b/dokan_control/dokanctl.c
@@ -22,6 +22,7 @@ THE SOFTWARE.
*/
#include
+#include
#include
#include
#include
@@ -29,6 +30,8 @@ THE SOFTWARE.
#include "../dokan/dokan.h"
#include "../dokan/dokanc.h"
+#define DOKAN_DRIVER_FULL_PATH L"%SystemRoot%\\system32\\drivers\\dokan.sys"
+
int ShowMountList()
{
DOKAN_CONTROL control;
@@ -142,11 +145,9 @@ wmain(int argc, PWCHAR argv[])
wcscat_s(mounterFullPath, MAX_PATH, L"\\mounter.exe");
fwprintf(stderr, L"mounter path %s\n", mounterFullPath);
- GetSystemDirectory(driverFullPath, MAX_PATH);
- wcscat_s(driverFullPath, MAX_PATH, L"\\drivers\\dokan.sys");
+ ExpandEnvironmentStringsW(DOKAN_DRIVER_FULL_PATH, driverFullPath, MAX_PATH);
fwprintf(stderr, L"driver path %s\n", driverFullPath);
-
if (GetOption(argc, argv, 1) == L'v') {
fprintf(stderr, "dokanctl : %s %s\n", __DATE__, __TIME__);
@@ -173,14 +174,26 @@ wmain(int argc, PWCHAR argv[])
switch(towlower(argv[1][1])) {
case L'i':
if (type == L'd') {
+
+ if(!PathFileExistsW(driverFullPath)) {
+ fprintf_s(stderr, "driver installation failed, the file does not exist.\n");
+ return EXIT_FAILURE;
+ }
+
if (DokanServiceInstall(DOKAN_DRIVER_SERVICE,
SERVICE_FILE_SYSTEM_DRIVER,
- driverFullPath))
+ DOKAN_DRIVER_FULL_PATH))
fprintf(stderr, "driver install ok\n");
else
fprintf(stderr, "driver install failed\n");
} else if (type == L's') {
+
+ if(!PathFileExistsW(mounterFullPath)) {
+ fprintf_s(stderr, "mounter installation failed, the file does not exist.\n");
+ return EXIT_FAILURE;
+ }
+
if (DokanServiceInstall(DOKAN_MOUNTER_SERVICE,
SERVICE_WIN32_OWN_PROCESS,
mounterFullPath))
@@ -189,9 +202,20 @@ wmain(int argc, PWCHAR argv[])
fprintf(stderr, "mounter install failed\n");
} else if (type == L'a') {
+
+ if(!PathFileExistsW(driverFullPath)) {
+ fprintf_s(stderr, "driver installation failed, the file does not exist.\n");
+ return EXIT_FAILURE;
+ }
+
+ if(!PathFileExistsW(mounterFullPath)) {
+ fprintf_s(stderr, "mounter installation failed, the file does not exist.\n");
+ return EXIT_FAILURE;
+ }
+
if (DokanServiceInstall(DOKAN_DRIVER_SERVICE,
SERVICE_FILE_SYSTEM_DRIVER,
- driverFullPath))
+ DOKAN_DRIVER_FULL_PATH))
fprintf(stderr, "driver install ok\n");
else
fprintf(stderr, "driver install failed\n");