Connecting to VPN with a Batch file

I have a batch file that I am passing parameters - it sets the username and password but the IKE connection fails - can someone check my batch file and tell me if it is correct?  also how can I tell what the value of the args are that are being passed to the console
any help would be greatly appreciated
@echo off

pushd "%programfiles%\checkpoint\securemote\bin"

if not exist scc.exe goto scc_missing

echo #### Setting command-line mode

scc.exe setmode cli

echo #### Setting login information


scc.exe userpass Username Password


echo #### Starting VPN connection

scc.exe connect -p Work

echo -

echo #### Testing connection

ping -w 1000 -n 4 10.10.0.18 > NUL

if errorlevel 1 echo Connection test failed!

if errorlevel 1 goto disconnect

if errorlevel 0 echo Connection tested OK!

:disconnect

echo -

echo #### Disconnecting..

scc.exe disconnect -p

echo #### Erasing login information

scc.exe erasecreds

echo #### Setting GUI (connect) mode

scc.exe setmode con

goto end

 

:scc_missing

echo #### SCC.EXE appears to be missing! Aborting..

goto end

 

:end

popd

echo #### Done!

pause

Open in new window

LVL 6
r3nderAsked:
Who is Participating?
 
sosinc3Connect With a Mentor Commented:
just replace the line to read as follows:

SCC.EXE USERPASS %1 %2

Then when you run the batch file, lets assume it is called vpn.bat, you would type

vpn sosinc3 "secret$password&ofthe^day"

That works for me on my PC here.

0
 
sosinc3Commented:
If you want to see what is happening during the running of this batch file either remove the first @ECHO OFF line or put REM (with a space after it) at the beginning of that line. That way you can see each line as it is getting processed. Also, you could insert several PAUSE commands throughout your batch file to make the process stop to see where it exactly is failing.
0
 
r3nderAuthor Commented:
This is what I get: - Is it saying the word Username and password were set or the username and password args were set

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Setting command-line mode
#### Setting command-line mode

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe setmode cli
Switched successfully to Command Line mode

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Setting login information
#### Setting login information

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe userpass YOURLOGIN YOURPASSWO
RD
Username, password were set.

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Starting VPN connection
#### Starting VPN connection

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe connect -p ETIHome
   Checking network connectivity...
   Preparing connection...
   Connecting to gateway...
   IKE negotiation failed
   Connection failed
Connect failed

C:\Program Files\CheckPoint\SecuRemote\bin>echo -
-

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Testing connection
#### Testing connection

C:\Program Files\CheckPoint\SecuRemote\bin>ping -w 1000 -n 4 10.10.0.18  1>NUL

C:\Program Files\CheckPoint\SecuRemote\bin>if errorlevel 1 echo Connection test
failed!
Connection test failed!

C:\Program Files\CheckPoint\SecuRemote\bin>if errorlevel 1 goto disconnect

C:\Program Files\CheckPoint\SecuRemote\bin>echo -
-

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Disconnecting..
#### Disconnecting..

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe disconnect -p
Already disconnected

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Erasing login information
#### Erasing login information

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe erasecreds
Credentials were unset OK.

C:\Program Files\CheckPoint\SecuRemote\bin>echo #### Setting GUI (connect) mode

#### Setting GUI (connect) mode

C:\Program Files\CheckPoint\SecuRemote\bin>scc.exe setmode con
Switched successfully to Connect mode

C:\Program Files\CheckPoint\SecuRemote\bin>goto end

C:\Program Files\CheckPoint\SecuRemote\bin>popd

C:\Documents and Settings\Michael\My Documents\Visual Studio 2008\Projects\VPNTe
st\VPNTest\bin\Debug>echo #### Done!
#### Done!

C:\Documents and Settings\Michael\My Documents\Visual Studio 2008\Projects\VPNTe
st\VPNTest\bin\Debug>pause
Press any key to continue . . .

Open in new window

0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
sosinc3Commented:
In your batch file, you need to actually put the real username and the password so the line that now reads

SCC.EXE USERPASS YOURLOGIN YOURPASSWORD should be for example

SCC.EXE USERPASS sosinc3 secretpassword    assuming the username name was sosinc3 and the password was secretpassword.

0
 
r3nderAuthor Commented:
Yeah I figured how to pass that in last night - I used SCC.EXE USERPASS  Username= %1 password=%2
That passed the arguments to the batch file - now I have another problem - our company allows users to use special characters in their password. So I have to figure a way to pass the password with the special character as a set string. For example
Set Caret= ^^  
if Password=%2 = "^" set "^"
Not sure how to do it but - I am still looking
0
 
sosinc3Commented:
I clicked on submit too quickly. Note how I have the whole password in quotation.
0
 
r3nderAuthor Commented:
yes that worked - so what I am doing is in the windows form - I get the username and password - then when I pass the args from the form to the bat file I added
string args = @"/c VPN.bat " + Username + " " + '"'+ Password + '"';
and TADA! ......it worked - I guess I can leave it like that and no matter what is typed - So in password it will be sent using the double quotes
0
 
r3nderAuthor Commented:
It was a pleasure to have learned from you
0
 
sosinc3Commented:
No problem. I am glad I was able to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.