2

I write the following VB script in order to run the CLI command - vpnclient.exe

my target is to automate the vpnclcient process and answer “y” when question appears,

I have WIN XP PC

During running the vpnclient.exe in CMD window we get then following question

     Do you wish to continue? (y/n):

In my VB I write the “echo y” in order to answer on this question automatically but question is still stuck in CMD window ,and I cant continue

please advice what chuld be wrong in my code and how to fix it?

MY VB script (vpnclient.exe – exist under VPN directory)

 Dim oShell
 Set oShell = WScript.CreateObject ("WScript.Shell")
 oShell.run "cmd /K CD C:\Program Files\Cisco\VPN  & ( echo y | vpnclient.exe connect  ""site moon"" )"
    Set oShell = Nothing
0

1 Answer 1

1

You can try by creating a file with the commands to be executed on the command line instead of echoing the password.

Here's an example where a text file is created first with the required command and then those commands are invoked from the file.

Public Function FTPDownload(serverName, ftpuser, ftppassword, dirPath, localpath, fileName) 
    Dim fso, myfile
    Set fso = CreateObject("Scripting.FileSystemObject")

    'Create FTP.EXE commands file
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set myfile= fso.OpenTextFile("C:\Regression\Results\ftp_cmd.ini", 2, True)
    myfile.WriteLine("open " &serverName ) 
    myfile.WriteLine(ftpuser)
    myfile.WriteLine(ftppassword)
    myfile.WriteLine("lcd " & localpath )
    myfile.WriteLine("cd " & dirPath)
    myfile.WriteLine("prompt")
    myfile.WriteLine("cr")
    myfile.WriteLine("mget *" &fileName &"*" )
    myfile.WriteLine("mdelete *" &fileName &"*" )
    myfile.WriteLine("close")
    myfile.WriteLine("quit")
    myfile.Close


    '====================The following code executes the FTP script. It creates a Shell object and run FTP program on top of it.===================
    Set objShell = CreateObject( "WScript.Shell" )
    objShell.Run ("ftp -i -s:" & chr(34) & "C:\Regression\Results\ftp_cmd.ini" & chr(34))
    Set objShell = Nothing

End Function
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.