Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to close correct window with this VBS

Posted on 2009-07-07
10
Medium Priority
?
769 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 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