I confirm the urgency of the problem. OpenVPN GUI for Windows in order to raise the interface and add routes requires elevation of rights, as a result, the disk mount script specified in the config is executed with administrator rights.
A distinct and tidy solution does not seem to exist.
Only came up with a crutch solution, through event logs.
In the connection config, specify the path to the script:
up 'c:\\Windows\\system32\\wscript.exe c:\\Program\ Files\\OpenVPN\\config\\up.vbs'
In the up.vbs script up.vbs create an entry in the event log with an ID equal to 777 (you can choose any other ID at your discretion):
Set WshShell = WScript.CreateObject("WScript.Shell") Command = "eventcreate /T Information /ID 777 /L Application /D " & Chr(34) & "VPN-соединение установлено." & Chr(34) WshShell.Run Command,0,false
When OpenVPN is connected to the event log, an event from EventCreate with ID = 777 will be added to the EventCreate .
In the task scheduler we create a task that is performed for a registered user, without elevation of rights.
On the Триггеры tab, we indicate:
- start of the task
При событии Application log- event code
777
On the Действия tab, specify the path to the disk mount script.
It can be made easier. Of course, if you do not confuse flashing windows command line. To do this, you can use the OpenVPN GUI features to run scripts . Instead of pp 1-2 Put the xxxx_up.cmd file in the config folder (where хххх is the name of an OpenVPN connection) of approximately the same content:
eventcreate /T Information /ID 777 /L Application /D "VPN-соединение установлено."
Then in the config do not need to refer to the script. When a connection is established, a black command window will appear for a split second, and the event will be added to the application log, after which the task scheduler will run and the disks will be mounted.
The method described above may be crooked, but it works quite well in production. At the time of the connection is not particularly affected. Users do not notice anything.
If you wish, you can create your own separate journal and write events in it, but this perfectionism is already beyond the scope of the problem.
Unmounting disks is done in the same way.