0

I'm trying to make automation using vbs and I'm wondering if it possible to build some simple gui with file chooser (or couple of them)? Googling didn't help me here.

I need this not to hardcode some input parameters of the script.

The original problem is ssh commands automation. I'm using XShell (ssh client) vbs scripts for this now, but I have to hardcode parameters everytime I use it. It would be better if I can just type ip/choose file, instaed of editing script.
Maybe it worth to consider any other ways of automation and if anybody can suggest any tools to automate sending ssh commands to remote server it would be great!

Thank you all in advance!

7
  • Even if you could, it's going to be a world of pain. Why not using something more suited to the task? Python springs to mind. Commented Jan 11, 2013 at 12:42
  • @DavidHeffernan, the thing is that i'm using XShell ssh client to connect to linux machines and it uses vbs for automation (Python is great instrument, but not applicable here, unfortunately). Maybe it worth to consider any other ways of automation. Can you suggest any tools to send ssh commands to remote server? Thanks. Commented Jan 11, 2013 at 12:46
  • Python can do COM automation just the same as VBS. Your automation is not tied to VBS. Commented Jan 11, 2013 at 13:01
  • @DavidHeffernan, I need tool to automate ssh commands, which senвы these commands from windows to linux server. I don't see any way of how python can be applied here (besides writing new python based ssh application). For now I'm using Xshell ssh client + vbs as such a tool. But I have to hardcode parameters of vbs scripts everytime I launch them. Commented Jan 11, 2013 at 13:15
  • 1
    you might be able to use VBScript in an HTA? Commented Jan 11, 2013 at 14:16

4 Answers 4

4

For people who know HTML it's very viable to write GUIs controled by VBScript (or any other ActiveScript language: Perl, Python, Ruby, JScript, ...). The technique is called HTML Application (HTA) and there is even a wizard/designer (of mediocre quality).

While command line VBScripts are hosted by C/WScript.exe, HTAs are browser (i.e. IE) based. That is not aproblem if you can do the SSH work via shelling out or COM objects. But Mr. Nothing's SSH client seems to be a console style application that hosts/uses VBScript code internally; in this case HTA is no option. OTOH: If - as "I need this not to hardcode some input parameters of the script" seems to indicate - the real work is done by starting VBScript scripts, then selecting/constructing parameters for such scripts in a HTA GUI should be easy (for HTML savvy people).

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

Comments

2

Writing a GUI in VBScript is not really viable. No doubt it's possible, but there aren't any toolkits that make it easy. It's not what VBScript was designed for.

There are a number of options that occur to me:

  • Write your GUI in another language, whatever you fancy. Then send commands to your VBscript code as command line arguments. That's the easiest option for you. All you need to do is write the GUI, and replace your hard-coded values in the VBscript code with some code that pulls values off the command line.
  • Do the COM automation of Xshell in a different language that supports COM automation. The majority of languages do. And write the GUI there too. For example, Python would be my choice.
  • Switch wholesale to a different language for both GUI and your ssh code. Again many languages exist with good modules for ssh.

2 Comments

Thanks for your patience, David! Could you, please, provide some links with clarification of COM automation and exmaples of how Python or, maybe, Perl can be used here.
There's lots of examples on the web. Here's one for automating Excel: excelicious.wordpress.com/2009/05/09/… Having said all that, the Xshell vbscript appears a bit odd. It looks like the scripts run inside the Xshell GUI. To be perfectly honest with you, Xshell doesn't look like such a great option to me.
1

Most of the problems involved with creating a VBScript UI is it lack of an event driven programming model. I have gotten past this problem by using Javascript and Internet Explorer events.

Declare the Internet Explorer object like below to enable events.

Set oIE = WScript.CreateObject("InternetExplorer.Application", "oIE_")

Declare the quit event like below. In this event quit the script.

Sub oIE_onQuit 

Declare the TitleChange event like below. In this event you will handle all the UI functions.

Sub oIE_TitleChange(text)

In the html the buttons that you want to trigger an even must have a javascript to change the title.

document.title = document.title;

Here is a link to the full source code.

Comments

0

While the answer about using HTA is good for complex UIs, for simpler inputs there are simpler alternatives worth mentioning as well.

One possibility that works with both JScript and VBScript, with both wscript and cscript is using the WSH.Arguments object. This will allow you to pass the inputs you care for on the command line in a terminal, or even drag-and-dropping them on top of the script file if they are other files. Note in JScript it is not a real array but somewhat array-like, i.e. has WSH.Arguments.length, but uses method-call syntax to get the items: WSH.Arguments.Item(0) or the shortcut WSH.Arguments(0).

Another option is to prompt the user and read his input. Both JScript and VBScript can do that with WSH.StdIn.ReadLine() in a terminal, i.e. when ran with cscript. When ran with wscript, the default when double-clicked, only VBScript can do it easily using the InputBox function like ResultVar = InputBox(prompt).

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.