I want to know a specific RAS connection (vpn) is connected or not.
The command line tools rasdial.exe and ipconfig.exe can list all RAS connections, but I intended to retrieve the vpn status frequently (maybe per 5 seconds), so I think it is best to use Dllcall.
(Another way is to query the IP address on a website, but this might take some time.)
The RasEnumConnections function seems can do this job, anyone can post an example? Thanks a lot!
How to retrieve all RAS connections using api?
Re: How to retrieve all RAS connections using api?
You are a pioneer, maybe show what you started with your pathfinder jobs.
Re: How to retrieve all RAS connections using api?
I found the WMI Win32_PerfFormattedData_RemoteAccess_RASTotal class, with a count total property qualifier.
It may do what you want and seems fast enough.
Please test this out and let me know if it counts the RAS connections.Untested
It may do what you want and seems fast enough.
Please test this out and let me know if it counts the RAS connections.
Code: Select all
CoordMode, Tooltip, Screen
Loop
{
For Item in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_PerfRawData_RemoteAccess_RASTotal")
ToolTip % (tc:=Item.TotalConnections) " RAS Connections Detected.`n"
. (!tc?"Waiting "(StrLen(s.=">")<10?s:(s:="")):"Connected."), 10, 10
}
ESC::ExitApp ; << press escape to exit.
Re: How to retrieve all RAS connections using api?
Thanks for the replies. I've tested the WMI code, no results here.
Who is online
Users browsing this forum: CoffeeChaton, mikeyww, peter_ahk and 130 guests