mithandir1 Posted June 7, 2022 Share Posted June 7, 2022 First of all I'm pretty sure I've done this the worst way possible. I need to launch "vpncli.exe connect 192.168.1.1" in a command prompt titled VPN. Then I need to controlsend keystrokes to get through the sign in process. The following code works, but it spawns an extra unneeded cmd window. How do I accomplish this without spawning the additional cmd window? $command = ('start cmd /k cmd & title VPN & "C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe" connect 192.168.1.1') Run(@ComSpec & " /c " & $command, "", @SW_HIDE) Sleep(500) ControlSend("VPN", "", "", "1") ControlSend("VPN", "", "", "{enter}") ControlSend("VPN", "", "", "UserID") ControlSend("VPN", "", "", "{enter}") ControlSend("VPN", "", "", "Password") ControlSend("VPN", "", "", "{enter}") ControlSend("VPN", "", "", "y") ControlSend("VPN", "", "", "{enter}") Link to comment Share on other sites More sharing options...
Luke94 Posted June 7, 2022 Share Posted June 7, 2022 The START command "Starts a separate window to run a specified program or command.". This should do the trick? $command = '"C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe" connect 192.168.1.1' Link to comment Share on other sites More sharing options...
Solution Luke94 Posted June 7, 2022 Solution Share Posted June 7, 2022 Replace the Run command with this as well: Run(@ComSpec & " /c title VPN & " & $command, "", @SW_SHOW) That'll change the title of the command prompt to VPN as well as show it. Link to comment Share on other sites More sharing options...
mithandir1 Posted June 7, 2022 Author Share Posted June 7, 2022 Perfect! The Run(@ComSpec & " /c title VPN & " & $command, "", @SW_SHOW) does exactly what I was trying to accomplish. Thank you so much for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now