Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to close correct window with this VBS

Posted on 2009-07-07
10
Medium Priority
?
774 Views
Last Modified: 2013-12-26
Hi guys, just wondering how to script this correctly to wait for the window to run the secureCRT application and THEN close the window.  Right now it is closing the first window that is open.  If I run this from explorer or from cscript from dos it will close those windows and then run secureCRT.  

Please help

Thanks
Dim objShell
Set objShell = Wscript.CreateObject("Wscript.Shell") 
 
objShell.run(Chr(34) & "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.EXE" & chr(34) & " /script D:\logs\Scripts\recordedScript.vbs")
 
 
objShell.AppActivate "192.168.1.79 - SecureCRT"
 
objshell.SendKeys "%{F4}"

Open in new window

0
Comment
Question by:MightySW
  • 7
  • 3
10 Comments
 
LVL 10

Expert Comment

by:TakedaT
ID: 24799130
I dont have the application to test, but you can try to add the bWaitOnReturn to the  run line like so.  Then you can also test for the return value depending on what it is.  If you want to run it from the cmd line, then you can begin the run line with a "cmd /c start" or something like that.

 Let me know how it works.
Dim objShell
Set objShell = Wscript.CreateObject("Wscript.Shell") 
 
iReturn = objShell.run(Chr(34) & "C:\Program Files\VanDyke Software\SecureCRT\SecureCRT.EXE" & chr(34) & " /script D:\logs\Scripts\recordedScript.vbs",1,True)
 
If iReturn = 0 then
	Success = objShell.AppActivate("192.168.1.79 - SecureCRT")
	If Success then
		wscript.sleep 100
		objShell.SendKeys "%{F4}"
	End if
End If

Open in new window

0
 
LVL 10

Accepted Solution

by:
TakedaT earned 2000 total points
ID: 24799258
I just googled it and it looks like since you are using a vbscript inside the program, you should just add "crt.quit"  to the end of the "recordedscript.vbs" file that you are calling.  Then there is no need to use the appactivate or sendkeys method in your original code.
0
 
LVL 20

Author Comment

by:MightySW
ID: 24799264
Thanks for the reply.  I tried the loop (exactly how you have it) and everything opens fine, but secureCRT still will not close.  At least nothing closed now.  Seems that the boolean is either set too soon, or success lost its value.  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 20

Author Comment

by:MightySW
ID: 24799269
I'll try it.
0
 
LVL 20

Author Comment

by:MightySW
ID: 24799293
From one MASTA TO ANOTHAHHH

Thanks bro, that did it!

Where did you find that dang command?  I even looked at the script manual for SecureCRT.
0
 
LVL 20

Author Closing Comment

by:MightySW
ID: 31600857
Thanks, I left a follow up question.

Can you just post the link.

Thanks again.  See you on the forums.
0
 
LVL 20

Author Comment

by:MightySW
ID: 24799316
0
 
LVL 20

Author Comment

by:MightySW
ID: 24799408
Just FYI and for anybody else that runs into this issue

Do this:

crt.Screen.Synchronous = False
before
crt.quit or else it will not write anything before disconnecting.
0
 
LVL 10

Expert Comment

by:TakedaT
ID: 24801274
I think it was this one:
http://forums.vandyke.com/showthread.php?t=1204

I also just ran across this one that looks useful:
https://www.vandyke.com/support/tips/scripting/creating.html

The more Im reading about this prog, the more I think I want to give it a try.  Could be mighty useful with all the cisco equipment I have to manage.  Thanks for the tip :D
0
 
LVL 20

Author Comment

by:MightySW
ID: 24804708
yeah, SecureCRT is by far the best when dealing with Cisco equipment.  It was recommended to me by a CCIE a long time ago and is still the preferred program for Cisco equipment.  Very versatile and cheap.

Thanks again for your help.  It is running well now.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question