I have self-written app in C++ that needs to connect specified VPN connection on my PC (the standard Windows VPN connection). When I had Windows 7 the app did this by getting IShellFolder pointer for the Network connections folder, then requested IContextMenu pointer for the specified connection and then called the InvokeCommand method (using the 2 as command ID which corresponded to the "Connect" item). It worked OK.
But now I moved to Windows 10 and this method does not work anymore - even if you open the Network Connections folder manually, right click the VPN connection and select "Connect / Disconnect", it will not start the connection process, it will open the tray popup menu instead where you can additionally click on the VPN connection name and then select "Connect". Exactly the same popup is now opened by my app.
I know that I can "dial" a VPN connection using the "RasDialDlg" function. But it always shows Username/password prompt dialog in Windows 10, so the VPN connection cannot be dialed instantly without any other user interaction. I also know that I can manually edit the RAS phonebook and set PreviewUserPw=0 to prevent this dialig from showing, but it's not a universal solution which I can then distribute to other PCs.
So, my question is: is there any way in Windows 10 to programmatically connect/disconnect a VPN connection without any user interaction from C++ app without modifying any system/user files?