SoftEtherVPN / SoftEtherVPN

Cross-platform multi-protocol VPN software. Pull requests are welcome. The stable version is available at https://github.com/SoftEtherVPN/SoftEtherVPN_Stable.
Apache License 2.0
11.71k stars 2.6k forks source link

Unable to create virtual adapter from CMD in Windows x64 #444

Open renjithkathirolil opened 6 years ago

renjithkathirolil commented 6 years ago

Hi,

I'm in the process of creating a VPN app for windows using softether.

I'm able to start vpnclient service but I'm unable to create virtual adapter using the following code : SoftEtherVPNClient\vpncmd_x64 localhost /CLIENT /CMD NicCreate VPN

The commands are run as administrator and the following errors are returned:

VPN Client>NicCreate VPN NicCreate command - Create New Virtual Network Adapter Error occurred. (Error code: 31) Installation of the Virtual Network Adapter device driver failed.

If VPNClientManager is running, the above error is not shown and adapter will be created. Is there any other way to create virtual adapter without running the VPNClientManager?

railty commented 5 years ago

Had the same issue, can create Adapter by VPNClient Manager without any problem, but cannot create from vpncmd, same error. happens in Windows 10 64

cuican6 commented 3 years ago

Hollo,Has the problem been solved,How to solve it。Thanks

davidebeatrici commented 3 years ago

Hello. Considering there were many changes since the last message in this issue, it's entirely possible the problem is solved.

cuican6 commented 3 years ago

I have tested with the latest release. Without installing softEtherclient, installing virtual network card with VPN CMD (nicreate VPN) will report err31 error

davidebeatrici commented 3 years ago

SoftEther VPN version?

cuican6 commented 3 years ago

4.34

davidebeatrici commented 3 years ago

Please try with the latest version from this repository.

cuican6 commented 3 years ago

hello,I has tested with least Version.

My scene is I want not install softether Client ,Only copy VPN clinet, VPN CMD and hamcore to the client,monitor softetherclient by vpncmd

davidebeatrici commented 3 years ago

Keep in mind that vpnclient has to be run as administrator though.

cuican6 commented 3 years ago

yes, i run vpncmd and vpnclient /install with administrator with least release,but vpncmd output Err ,Errcode 31,thanks ,man

Kiritzai commented 3 years ago

I've kinda figured out why it gives these errors while using vpncmd.exe or vpncmd_x64.exe. Always used another VPN but I was lacking alot of features and especially the GUI, damn... I love the GUI of SoftEther. The installation is also really easy for SoftEther Server on a debian server, so that's a REAL plus for me! Only thing I'm missing is the dnsmasq integration or management from SoftEther GUI, but that's fine for me.

Sorry.. hehe, now back to the errors. The problem is that SoftEther needs vpncmgr.exe or vpncmgr_x64.exe to start first before running the vpncmd commands. When running vpncmgr.exe or vpncmgr_x64.exe, it creates a folder in %TEMP% ( C:\Users\%username%\AppData\Local\Temp ) with it's contents apparently, which are needed to run the NicCreate command for example. ( drivers ) Also make sure to create the service, else it wont connect properly to the localhost's SoftEther Client.

I'll share a part of my silent installation script for now.

$serviceName = "sevpnclient"
$InstallationPath = "C:\Program Files\SoftEther VPN Client"

# Installs service  
$serviceExists = $null
$serviceExists = Get-Service "sevpnclient" -ErrorAction SilentlyContinue
If ($serviceExists -eq $null) { 
    $binPath = Join-Path $InstallationPath 'vpnclient_x64.exe'
    New-Service -Name "sevpnclient" -BinaryPathName "$binPath /service" -DisplayName "SoftEther VPN Client" -StartupType "Automatic" -Description "This manages the Virtual Network Adapter device driver and connection service for the SoftEther VPN Client. When this service is stopped, it will not be possible to use SoftEther VPN Client on this computer to connect to a SoftEther VPN Server."
}

# Starting new installed service
Start-Service -Name "sevpnclient"

# Making sure service runs
$serviceInfo = Get-Service -Name $serviceName

while ($serviceInfo.Status -ne 'Running') {
    Start-Sleep -Seconds 3
    $serviceInfo.Refresh()
}

$vpnCmgrPath = Join-Path $InstallationPath 'vpncmgr_x64.exe'
$p = Start-Process $vpnCmgrPath -WindowStyle Hidden -PassThru

while (!(Get-Process -Id $p.Id -ErrorAction SilentlyContinue)) {
    Start-Sleep -Seconds 1
}

# Just wait for the application load its contents
Start-Sleep -Seconds 5

# Kills process
Stop-Process $p -Force

Partly the source: https://gist.github.com/checkin247/df20b55f55529b70d141b4db2cf5061a

After this it's possible to run NicCreate with VPNCMD

checkin247 commented 3 years ago

@Kiritzai if you check my chocolatey installer script you will realise that it installs an nssm service on windows which enables you to allways use the softether commands. This has the advantage that you don't first have to start a process or check the health of that process. The nssm dependency is also super light.

Kiritzai commented 3 years ago

@checkin247 Oh I see :). The thing is that I don't want a third party application to be installed, so that's why i'm doing it this way :)