I did even more research on this topic, and found something very useful that I use now instead of my own little batch file as it does what I want it to do, and that always when I connect to a wifi, and does not only check on startup. Using this task from within the windows task scheduler, it runs in the background, and I never had to think about it since I configured it.
These 2 xml files have to be edited exactly how the installation instructions describe it, and then it works just fine for my needs. There is also the possibility to disable all popups, but in order for this to work, you need your password for the OpenVPN connection to be stored in plain text next to the config file, which I don’t want to do. If you do this, you have to be very careful, whoever gets his hand on both of these files will be able to connect to your vpn server (which is probably in your home LAN behind all firewalls!) with your credentials and thus can steal data or even place viruses throughout the network. Considering this, I would definitely not recommend to use this option and rather type in the password manually every time the laptop connects to a different wifi than your home’s.
Also the second task, which handles the disconnection whenever your disconnect from a wifi works well. It just kills every task with “openvpn” in it’s name, so you are good to go for the next connection.
I did not figure this out by myself, all credits go to Carlin Scott who wrote the tasks. I just wanted to share my results with you as you helped me very much with the first solution.
CLICK HERE to find out more related problems solutions.