×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Is there a way to convert a VBscript.vbs into an EXE?

Is there a way to convert a VBscript.vbs into an EXE?

Is there a way to convert a VBscript.vbs into an EXE?

(OP)
I have written a Vbscript.vbs and needs to compile it into an EXE.  Someone can easily modify the script file with a text editor.


Any help?

RE: Is there a way to convert a VBscript.vbs into an EXE?

Well put it into VB and compile it.  Do you have a copy of regular VB?

RE: Is there a way to convert a VBscript.vbs into an EXE?

(OP)
No.  I have Visual C++ 6.0 but don't know much about its language.


If I could get the C++ Syntax to run the script from within a C++ EXE, I am in business.  I have been trying at customizing a simple C++ project but I need the code lines that runs the script....

RE: Is there a way to convert a VBscript.vbs into an EXE?

Thats a good way to do it if the only reason you need an EXE is to keep peeps from changing your source.

I give you a star!

RE: Is there a way to convert a VBscript.vbs into an EXE?

(OP)
Thanks PH, but I would also want to start my app with an EXE, it is more 'professional' I would say.

RE: Is there a way to convert a VBscript.vbs into an EXE?

it is more 'professional'
So, use professional tools  

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244

RE: Is there a way to convert a VBscript.vbs into an EXE?

Either translate it into C or beg/borrow/steal a VB compiler.

RE: Is there a way to convert a VBscript.vbs into an EXE?

(OP)
Thanks Guys, I succeeded in creating an EXE that runs the VBscript.

My Trouble now is to Encode the Script.  I can't get it to be 'baked' in the EXE that I have created in C++.

Neither can I get a nice icon for my created C++ EXE.  I will forego this in the mean time.

RE: Is there a way to convert a VBscript.vbs into an EXE?

Just to know, what are you doing in VBS you can't do in C++ ?

RE: Is there a way to convert a VBscript.vbs into an EXE?

You can also create the script on the fly with the executable you wrote, spawn wscript.exe to run it, then delete the script file.

You can also check out Free Basic Scripting Language, which is a free scripting language similar to Basic that has a compiler in it.  It has its own file handling functions built in.  Variable naming is similar to the old BASIC style, with % and $.

Lee

RE: Is there a way to convert a VBscript.vbs into an EXE?

Another option that might meet the need is to write most of the logic as an ActiveX control (OCX) in VB5CCE, then host the control in an HTA.  I don't recall if it can create ActiveX DLLs, but if it can you might then host these in WSH scripts too.

This would allow most of the logic to be presented in compiled form, without the need to rewrite it in a radically different language.  An HTA can't have an embedded icon like an EXE can, but it can indeed have an icon that appears in the window's title bar and the Windows Task Bar.  You can always use that icon as a shortcut icon as well.

VB5CCE was once hosted as a free download by Microsoft, and was also included on companion CDs packaged with many books.  I'm not sure about 3rd-party sources of VB5CCE downloads now - they may not be considered "legit" even though this was always a free product.  I'd be careful to virus-scan any such files from 3rd party sources.  They may also omit the Help file downloads that belong to the VB5CCE distribution.

I see one possible source at Visual Basic Game Programming With DirectX but I can't vouch for it.

RE: Is there a way to convert a VBscript.vbs into an EXE?

Great!

I was under the impression it was gone, like Microsoft's FTP site and most DOS-related downloads.

Thank you for correcting my error, tsuji.

I can't seem to find the documentation (help) files for this product except at Microsoft's Japanese downloads.  I did find a couple of "fixes" and such:

VB5CCE FAQ
Visual Basic 5.0 Control Creation Edition : Picclip Update Module
VB5cli.exe Fixes Visual Basic 5.0 Control Installation Problem

That's about all I dug up though, aside from:

Service Pack 3 - Readme which may not install with VB5CCE since it was for Pro and Enterprise.

RE: Is there a way to convert a VBscript.vbs into an EXE?

I tried VB5CCE on a "clean" system, a Windows 95 installation that never had any developer tools on it.

I started with a small script:

Jabber.vbs

CODE

Option Explicit

Function Jabber()
    Const ForReading = 1
    Dim FSO
    Dim strIn
    Dim tsIn
    Dim strOut
    Dim tsOut
    Dim strLine

    Set FSO = CreateObject("Scripting.FileSystemObject")
    strIn = InputBox("File to Jabber")
    If StrIn = "" Then
    Jabber = True
        Exit Function
    End If
    strOut = InputBox("New jabbered file")
    If strOut = "" Then
        Jabber = True
        Exit Function
    End If
    Set tsIn = FSO.OpenTextFile(strIn, ForReading)
    Set tsOut = FSO.CreateTextFile(strOut, True)
    Do Until tsIn.AtEndOfStream
        strLine = tsIn.ReadLine
        strLine = Replace(strLine, "a", vbFormFeed)
        strLine = Replace(strLine, "e", "a")
        strLine = Replace(strLine, "i", "e")
        strLine = Replace(strLine, "o", "i")
        strLine = Replace(strLine, "u", "o")
        strLine = Replace(strLine, vbFormFeed, "u")
        tsOut.WriteLine strLine
    Loop
    tsOut.Close
    Set tsOut = Nothing
    tsIn.Close
    Set tsIn = Nothing
    Set FSO = Nothing
    Jabber = False 'No cancels.
End Function

WScript.Echo "Start!"
If Jabber() Then
    WScript.Echo "Canceled!"
Else
    WScript.Echo "Done!"
End If
Then I started up VB5CCE and created an ActiveX control project.  I named the project Jabber and the UserControl Compiled.

Next I copied in the VBScript code for the function Jabber() into the UserControl's code window.  Because VB5 did not have the Replace() function yet, I faced a decision.

One way would be to write my own Replace() using the string functions already in VB5.  The other is to write a function in the calling script that invokes VBScript's Replace, and pass the calling script to the VB5 version of Jabber() as an Object, then invoke the function from the script as a method.

I chose the latter, and I called my Replace() wrapper function R().

Here is the VB5CCE code:

Compiled.ctl

CODE

Option Explicit

Public Function Jabber(ByVal Caller As Object)
    Const ForReading = 1
    Dim FSO
    Dim strIn
    Dim tsIn
    Dim strOut
    Dim tsOut
    Dim strLine

    Set FSO = CreateObject("Scripting.FileSystemObject")
    strIn = InputBox("File to Jabber")
    If strIn = "" Then
        Jabber = True
        Exit Function
    End If
    strOut = InputBox("New jabbered file")
    If strOut = "" Then
        Jabber = True
        Exit Function
    End If
    Set tsIn = FSO.OpenTextFile(strIn, ForReading)
    Set tsOut = FSO.CreateTextFile(strOut, True)
    Do Until tsIn.AtEndOfStream
        strLine = tsIn.ReadLine
        strLine = Caller.R(strLine, "a", vbFormFeed)
        strLine = Caller.R(strLine, "e", "a")
        strLine = Caller.R(strLine, "i", "e")
        strLine = Caller.R(strLine, "o", "i")
        strLine = Caller.R(strLine, "u", "o")
        strLine = Caller.R(strLine, vbFormFeed, "u")
        tsOut.WriteLine strLine
    Loop
    tsOut.Close
    Set tsOut = Nothing
    tsIn.Close
    Set tsIn = Nothing
    Set FSO = Nothing
    Jabber = False 'No cancels.
End Function
Not much has changed here from the original VBScript version.  I saved the project and compiled it, which registers the new Jabber.ocx on that machine in passing.

Then I slightly rewrote the calling script:

Jabber Compiled.vbs

CODE

Option Explicit

Dim Jabber

Function R(ByVal Expression, ByVal Find, ByVal ReplaceWith)
    R = Replace(Expression, Find, ReplaceWith)
End Function

WScript.Echo "Start!"

Set Jabber = CreateObject("Jabber.Compiled")
If Jabber.Jabber(Me) Then
    WScript.Echo "Canceled!"
Else
    WScript.Echo "Done!"
End If
Set Jabber = Nothing

The results:

orig.txt

CODE

this is some text to be converted to
jabbering by the script Jabber.vbs

it should look very strange after it
has been rendered into pure jabber
by the Jabber script.

always rely on Jabber for the finest
in jabbering!

jabbered.txt

CODE

thes es sima taxt ti ba cinvartad ti
jubbareng by tha scrept Jubbar.vbs

et shiold liik vary strunga uftar et
hus baan randarad enti pora jubbar
by tha Jubbar scrept.

ulwuys raly in Jubbar fir tha fenast
en jubbareng!
The only deployment issue is making sure that the VB5 runtime is installed on target machines, and that Jabber.ocx gets copied and registered, such as by running:

          regsrv32 {path}Jabber.ocx

This can be done from a command prompt or Start|Run dialog.  One could also create an OCX installer package, etc.

I think this is as close as you can get "for free" to compiling VBScript.  One might replace the calling script by using some free compiler for a language that supports ActiveX objects.  Then you'd have a 100% solution.

You can also easily use things like the Common Dialog control in VB5CCE to provide a nicer file dialog than you get by using Inputbox().  Adding a reference to the Microsoft Scripting Runtime lets you use early binding and defines the FSO constants, and for that matter you can use typed variables for better performance.

If the script does a lot of work, rewriting it as an ActiveX control like this may increase performance generally.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close