View Single Post
  #15  
Old 23.08.2021, 21:06
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 64,114
Default

I've found one possibly fatal mistake in this CMD script:
Code:
start /b "" "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --silent_connection 1 --connect %filename%
"%filename%" will contain the filename of the config file.
If that contains bad chars such as spaces or "-" this may lead to issues so you need to wrap it in quotation marks.
A lot of users might use the "premiumize.me" OpenVPN config files.
Their (new) default premiumize.me config files filenames e.g. contain spaces and a "-" which will result in a failure when being used with the first version of the above CMD script.

I've made some minor changes and this one worked fine for me:
Click on "Spoiler: show" to view the batch script!
Spoiler:

Code:
@ECHO OFF
SETLOCAL
SET "openvpndir=C:\Program Files\OpenVPN"
SET "openvpndir_config=%openvpndir%\config"
SET "openvpndir_bin=%openvpndir%\bin\openvpn-gui.exe"

REM TODO: Write a file in order to be able to know the last used config -> Avoid connecting to the same one as before again thus wasting time!
FOR /f %%a IN (
 'dir /b /a-d "%openvpndir_config%\*.ovpn"^|find /i /c ".ovpn" '
 ) DO SET /a selection=1 + (%RANDOM% %% %%a)
FOR /f "tokens=1*delims=:" %%a IN (
 'dir /b /a-d "%openvpndir_config%\*.ovpn"^|findstr /n /i ".ovpn" '
 ) DO IF %%a==%selection% SET filename=%%b


REM exit OpenVPN if it's running
echo Killing OpenVPN
REM TODO: Do not display errors in console for this one
taskkill.exe /F /IM openvpn.exe
echo Re-opening OpenVPN
REM TODO: Do not display errors in console for this one
taskkill.exe /F /IM openvpn-gui.exe
echo Sleep after kill
ping localhost -n 5>nul

echo connecting to VPN config: %filename%
start /b "" "%openvpndir_bin%" --silent_connection 1 --connect "%filename%"
REM If we don't do this JD might detect our non proxy VPN as new IP which would be wrong!
echo Sleep some seconds before batch exit
ping localhost -n 10>nul
GOTO :EOF


-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenver​ein kein Ort für Amoklaufide​en ist

Last edited by pspzockerscene; 24.08.2021 at 18:57.
Reply With Quote