OpenVPN / openvpn-build

OpenVPN Build
326 stars 238 forks source link

Cannot install on Windows 10: a script required for this install to complete could not be run #521

Closed rportron closed 10 months ago

rportron commented 11 months ago

Hi,

I am trying to install the latest OpenVPN Community (2.6.7 and 2.6.8) on a Windows 10 (Pro edition, 64bits, up to date) and I am seeing the following error: image

I saw that a similar issue was resolved : #397 but unfortunately it didn't help me to resolve mine.

The command sc query OpenVPNService gives The specified service does not exist as an installed service.

I have tried with the antivirus deactivated without any further success

I also tried msiexec /i OpenVPN-2.6.7-I001-amd64.msi /L*V install.log but analysing the logs didn't help me:

Action 14:02:25: CheckOpenVPNServiceStatus. Checking status of OpenVPNService Action start 14:02:25: CheckOpenVPNServiceStatus. Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CheckOpenVPNServiceStatus script error -2147217392, SWbemObjectSet: Classe non valide Line 25, Column 5, MSI (s) (00:D8) [14:02:26:451]: Product: OpenVPN 2.6.7-I001 amd64 -- Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CheckOpenVPNServiceStatus script error -2147217392, SWbemObjectSet: Classe non valide Line 25, Column 5, Action ended 14:02:26: CheckOpenVPNServiceStatus. Return value 3. MSI (s) (00:60) [14:02:26:574]: Note: 1: 2265 2: 3: -2147287035

Is there a way to install this missing service before the installation?

krisavi commented 10 months ago

I have same error when I try to uninstall currently installed version and cannot seem to install any of them any 2.6.x versions any more. Neither I can install 2.5.x because it reports newer version already being installed. But the uninstall that failed with same error removed some of the files so I do not have working OpenVPN and doesn't seem like there is any way to uninstall not install them.

lstipakov commented 10 months ago

What happens if you create test.js file with content:

var _serviceName = "OpenVPNService";

function IsServiceExist() {
    var wmi = GetObject("winmgmts://./root/cimv2");
    var svcs = wmi.ExecQuery("Select * from Win32_Service where Name = '" + _serviceName + "'");
    return svcs.Count > 0;
}

WScript.StdOut.Write("begin\n");

if (!IsServiceExist())
    WScript.StdOut.Write("Service "+ _serviceName + " doesn't exist\n");
else
    WScript.StdOut.Write("Service "+ _serviceName + " exists\n");

WScript.StdOut.Write("end\n");

and then run it:

cscript test.js

lstipakov commented 10 months ago

I am not too much into WMI / Windows Scripting and not sure why in rare cases WMI might not work. I wonder if in these cases we should just catch an error and assume that OpenVPNService doesn't exist. This means that it won't be started and configs won't be migrated, but that is probably okay taking into account the current alternative (installation broken). @selvanair @flichtenheld do you have any thoughts?

rportron commented 10 months ago

What happens if you create test.js file with content:

(...)

cscript test.js

Thanks a lot for your help, here below what happened:

`PS C:\Users\aym\Documents> cscript test.js
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. Tous droits réservés.

begin
C:\Users\aym\Documents\test.js(6, 5) SWbemObjectSet: Classe non valide`

It says: not a valid class...

krisavi commented 10 months ago

I did not create the cscript, but can send from sc query result... Notice the service name. I have not changed it or anything on my own, it is just as it came from OpenVPN 2.6.0 installation. Could be possible that the script checks wrong service during uninstall and installation and gives error.

PS C:\Users\dev> sc query OpenVPNServiceInteractive

SERVICE_NAME: OpenVPNServiceInteractive
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

However the cscript gives

PS C:\Users\dev\Downloads> cscript test.js
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

begin
C:\Users\dev\Downloads\test.js(6, 5) SWbemObjectSet: Invalid class

That seems to indicate that var svcs object doesn't have .Count. Same error when I try with OpenVPNServiceInteractive

I ended up going through steps in here since had same errors in mmc.exe - WMI snap-in about a lot of Win32_* missing. https://learn.microsoft.com/en-us/answers/questions/684166/failed-to-initialize-all-required-wmi-classes

lstipakov commented 10 months ago

Could be possible that the script checks wrong service during uninstall and installation and gives error.

I don't think so - service name should not cause this error. For example:

C:\Temp>cscript test.js
Microsoft (R) Windows Script Hostin versio 5.812
Copyright (C) Microsoft Corporation. Kaikki oikeudet pidätetään.

begin
Service OpenVPNService123 doesn't exist
end

There must be something wrong with WMI on affected machines.

@krisavi Have you solved this issue with those steps?

krisavi commented 10 months ago

I solved problem for me by recreating WMI database because it seemed to report that Win32_Service does not exist, however it should be valid class for all machines. There can be components that are not on every machine, but Win32_Service is not one of them.

rportron commented 10 months ago

I solved this issue with the following command: winmgmt /resetrepository

After that I was able to install the latest version of OpenVPN

rgristroph commented 2 months ago

I also had this issue, across a number of mostly identical Windows 10 machines. Running "winmgmt /resetrepository" in a cmd.exe launched with Administrator privileges as rporton describes above worked.

Should the installer suggest this if it runs into this condition, or even just run the repository reset ? Suggesting the fix in an error message might be something I could do a PR for.

ba5il commented 1 month ago

Thanks. The command 'winmgmt /resetrepository' fixed the problem