Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to compile vbs code into exe?

Status
Not open for further replies.

nealbailey

IS-IT--Management
Aug 19, 2003
3
0
0
US
Hi all! Great Site,

Quick question..I've been writing vb scripts like crazy (for the purpose of sys-admin at my job) and I'd like to program an all-in-one tool in a compiled executable (complete with menus and such). Once I dust off my old copy of VB 6.0 Pro can I expect any runtime or debug errors with pasting my vbs functions into this VB program? Curious if VB6 will know how to handle newer vbs objects like WMI or WSH or will it not make any difference?

Thanks..
 
Thanks for the response:

Interesting article. Compiling the code is not necessarily the goal though. Perhaps I just want too much. I'd like to use my existing scripts but with a friendly GUI front-end (so my techs won't be so confused). Something simple like a series of buttons corresponding to each script (to consolidate 50 or more). I can do that in VB, just worried that it will give me syntax error while trying to compile the code...
 
I'm trying to remember...

Most of what will give you grief is stuff like the Execute statement that isn't in VB6. I can't remember if you'll get away with using variants for object references in VB6. I seem to remember several differences with late-binding objects but without it in front of me I'm drawing a blank.

Usually what I do to try to achieve what you're after is to use IE to host the script rather than WSH. Just create HTAs instead of HTMs, and so on. For internal use things that are missing from the IE scripting environment (such as the Sleep() method) can be done with a small VB6 ActiveX object of your own to make the Win32 API calls. An HTA has relaxed security restrictions and can use the FSO and general ActiveX components freely.

This gives you a nice GUI scripting environment in which you can use both VBScript and JScript (some things are easier in JScript). Since compiled code speed isn't your goal this would do the job nicely.

There is a simple example at:


Just scroll halfway down the page and look for "vbsForm." There's a "dual demo" download. One HTA is a GUI installer for the second demo, a simple GUI file-access script as an HTA.
 
Also take a look at freeware controls nonModalDialog and wshDialog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top