Help with Connect CLI

Can anyone help me with a batch script using the CLI?

IWe just recently moved from Dell SonicWall to Sophos. We had a few batch scripts utilizing the NetExtender CLI that I'd like to convert over to use with the Connect CLI.


The first is a connection script that first checks if the VPN is already connected and then connects if it isn't.


Here's what it looked like with NetExtender:


@echo off
set NEDIR="C:\Program Files (x86)\SonicWALL\SSL-VPN\NetExtender"
chdir /d %NEDIR%
for /f "Tokens=2" %%i in ('NECLI showstatus') do set NESTATUS=%%i
if %NESTATUS% == Disconnected (
start NEGui.exe
NECLI connect -s -u matt -p #Matt2017 -d ap.local
) else (
Echo Already Connected


I am definitely not a command prompt expert, so I've tried to make heads or tails out of this and convert it, but it's not working.


I was trying to use the sccli get command to get the status of a connection and search for the text "Connected: 0" which appers in the output, but I'm not doing something right. Again, just not knowing what I'm doing with Windows Command Prompt well enough.


set SCDIR="C:\Program Files (x86)\Sophos\Connect"
chdir /d %SCDIR%
for /f "Tokens=2" %%i in ('sccli get -n AP_Sophos_Connect') do set SCSTATUS=%%i
if sccli get -n AP_Sophos_Connect | findstr "Connected: 0" (
sccli enable -n AP_Sophos_Connect
) else (
Echo Already Connected


Any help is appreciated!!!