Jump to content

VBScript Help - .vbe To Execute A Batch File Silently


Recommended Posts

Ok I need some help from the VB Script Guru's out there. Ive been messing around with the SwitchBlade but need a feature from it pulled so I can use it for something else. As all of you know, when executing a batch file, a command window pops up which is not very stealth like. SwitchBlade fixs this by having a "VBScript Encoded Script File" named "go.vbe" on the emulated cd-rom that simply executes the "go.cmd" batch file on the thumb drive silently with no windows popping up.

Now I need another one of these ".vbe" VBScripts to execute a batch file for me that has a different name. I can not edit this current one as its just jibberish when you open it.

All I need is a simple ".vbe" VBScript that will silently execute a batch file named "execute.bat" located in the same directory as the ".vbe" script.

Can any fellow haklings help me out with this. Simply have it run a batch file named "execute.bat" that will be located in the same exact directory as the script, but run it silently, with no command windows popping up.

Any help at all is appreciated!

Thanks... 8)

Link to comment
Share on other sites

It doesn't necessarily have to be a vbe script, it can also be vbs. Use the following vbs script to decode a vbe file, and then just change go.cmd to whatever you want.

option explicit

Dim oArgs, NomFichier

'Optional argument : the encoded filename


Set oArgs = WScript.Arguments

Select Case oArgs.Count

Case 0 'No Arg, popup a dialog box to choose the file

    NomFichier=BrowseForFolder("Choose an encoded file", &H4031, &H0011)

Case 1

    If Instr(oArgs(0),"?")=0 Then '-? ou /? => aide


    End If

Case Else

    WScript.Echo "Too many parameters"

End Select

Set oArgs = Nothing

If NomFichier<>"" Then

    Dim fso

    Set fso=WScript.CreateObject("Scripting.FileSystemObject")

    If fso.FileExists(NomFichier) Then

        Dim fic,contenu

        Set fic = fso.OpenTextFile(NomFichier, 1)



        Set fic=Nothing

        Const TagInit="#@~^" '#@~^awQAAA==

        Const TagFin="==^#~@" '& chr(0)

        Dim DebutCode, FinCode




            If DebutCode>0 Then

                If (Instr(DebutCode,Contenu,"==")-DebutCode)=10 Then 'If "==" follows the tag


                    If FinCode>0 Then

                        Contenu=Left(Contenu,DebutCode-1) & _

                        Decode(Mid(Contenu,DebutCode+12,FinCode-DebutCode-12-6)) & _


                    End If

                End If

            End If

        Loop Until FinCode=0

        WScript.Echo Contenu


        WScript.Echo Nomfichier & " not found"

    End If

    Set fso=Nothing


    WScript.Echo "Please give a filename"

    WScript.Echo "Usage : " & wscript.fullname  & " " & WScript.ScriptFullName & " <filename>"

End If

Function Decode(Chaine)

    Dim se,i,c,j,index,ChaineTemp

    Dim tDecode(127)

    Const Combinaison="1231232332321323132311233213233211323231311231321323112331123132"

    Set se=WSCript.CreateObject("Scripting.Encoder")

    For i=9 to 127



    For i=9 to 127


        For j=1 to 3


            tDecode(c)=Left(tDecode(c),j-1) & chr(i) & Mid(tDecode(c),j+1)



    'Next line we correct a bug, otherwise a ")" could be decoded to a ">"

    tDecode(42)=Left(tDecode(42),1) & ")" & Right(tDecode(42),1)

    Set se=Nothing





    For i=1 to Len(Chaine)


        If c<128 Then index=index+1

        If (c=9) or ((c>31) and (c<128)) Then

            If (c<>60) and (c<>62) and (c<>64) Then

                Chaine=Left(Chaine,i-1) & Mid(tDecode(c),Mid(Combinaison,(index mod 64)+1,1),1) & Mid(Chaine,i+1)

            End If

        End If



End Function

Function BrowseForFolder(ByVal pstrPrompt, ByVal pintBrowseType, ByVal pintLocation)

    Dim ShellObject, pstrTempFolder, x

    Set ShellObject=WScript.CreateObject("Shell.Application")

    On Error Resume Next

    Set pstrTempFolder=ShellObject.BrowseForFolder(&H0,pstrPrompt,pintBrowseType,pintLocation)


    If Err.Number<>0 Then BrowseForFolder=""

    Set pstrTempFolder=Nothing

    Set ShellObject=Nothing

End Function

PS. I didn't write this myself, but found it somewhere. I don't know who the original author is, but all creditz go to him (or her).

Link to comment
Share on other sites

2 questions

1) Is there any way to output the decode to a text file? It displays it in a window and cant make out some of the characters, for example how many """ there are in parts. Output to a text file would help.

Heres the output:


2) You would happen to have another VBS file that re-encodes the .vbs into a .vbe again after I modify it, would you?

thanks again

Link to comment
Share on other sites

Nevermind got it working. Just typed out that code from the image and then cut it down until it only had what I needed.

For anyone else who wants something similar, here:

If CreateObject("Scripting.FileSystemObject").FileExists("execute.bat") Then

CreateObject("Wscript.Shell").Run "execute.bat", 0, False

End If

Link to comment
Share on other sites

It's not necessary to make it into a vbe, it will run as vbs too, but you can always download the windows script encoder from microsoft.

thanks, I know, figured that out during the process of getting the above to work. I prefer it coded as a .vbe just so it cant be viewed or modified but any average joe. I realize its not to difficult to decode, just enough to stop the average user.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...