NordVPN-switcher
NordVPN-switcher copied to clipboard
Encountering "The handle is invalid" error when using subprocess.Popen with shell=True
Description
I'm encountering an error when using nordvpn_switcher
to interact with the NordVPN application. I run it from RStudio. Freshly installed Python. The error message is:
OSError: [WinError 6] The handle is invalid
This error occurs specifically in the initialize_VPN
function on line 152 of nordvpn_switch.py
. The relevant code snippet is:
open_nord_win = subprocess.Popen(["nordvpn", "-d"], shell=True, cwd=cwd_path, stdout=DEVNULL)
I understand the security concerns associated with using shell=True
and have explored alternative approaches. I've reviewed the documentation but haven't found a documented method to bypass external commands for running NordVPN actions.
Steps to reproduce:
- Install
nordvpn_switcher
. - Run a script that utilizes
nordvpn_switcher
and attempts to connect or disconnect using the library.
Expected behavior:
The nordvpn_switcher
library should successfully interact with the NordVPN application without encountering any errors.
Actual behavior:
The script throws the "The handle is invalid" error when the initialize_VPN
function attempts to run the nordvpn
command using subprocess.Popen
with shell=True
.
Additional context:
- I'm using
nordvpn_switcher
version 20240228. - I'm running the script on a Windows system 10.
I would appreciate any guidance or assistance in resolving this issue.
Thank you for your time and support.