Joe_E
Tue Jan 24 06:51:41 CST 2006
A workaround is to use the iexpress.exe tool that ships with Windows
(2000 & beyond).
This tool allows you to create an EXE made up of a number of source
files into a single EXE.
Steps:
Let's assume you want to create myScript.exe that runs myScript.vbs
when a user double-clicks on the file (myScript.exe). Let's assume
further that you want myScript.vbs to be run using Cscript.exe as the
scripting host
* make sure that your script file name is in the short name format
(i.e. no longer that 8 characters and contains no spaces -->
myscript.vbs and not --> my script sample.vbs)
* create a batch file to run myScript.vbs and save this to the same
directory as myScript.vbs. See batch file for this is at bottom of this
thread
* From the start menu type IEXPRESS and select RUN
* When the IEXPRESS WIZARD pulls up select 'Create New self extracting
directive' and click NEXT
* On the PACKAGE PURPOSE screen select 'Extract files and run an
installation command' and click NEXT
* On the PACKAGE TITLE screen enter a descriptive name and click NEXT
* On the CONFIRMATION PROMPT select whether or not you want a prompt to
be shown to users before running and click NEXT
* On the LICENSE AGREEMENT screen you can specify a text file
containting a license that will be displayed to users. If you enable
this feature, users are prompted to accept alicense agreement by
clicking YES before the script will run
* On the PACKAGED FILES screen, click on ADD and then add the
myScript.bat and myScript.vbs files by navigating to the folder where
these files are stored. Once all files are added, click NEXT
* on the INSTALL PROGRAM TO LAUNCH screen select myScript.bat from the
INSTALL PROGRAM drop down list and click NEXT
* on the SHOW WINDOW screen leave 'Default' selected and click NEXT
* On the FINISHED MESSAGE screen you can enter a brief note to display
in a dialog box once the script completes. If not needed leave NO
MESSAGE selected and click NEXT
*On the PACKAGE NAME AND OPTIONS screen, click BROWSE and specify the
EXE file name that should be created, e.g. myScript.EXE. Under options
you can choose to hide the extraction window. I don't use the 'Store
File names ...' option but you could if needed. Click NEXT when done
* On the CONFIGURE RESTART screen you can define restart options for
the package . If no restart needed then select NO RESTART and click
NEXT
* You can save the package directive file on this last screen. Cick
NEXT to move on to the CREATE PACKAGE screen and click NEXT to create
the package (i.e. myScript.exe)
Package is then created and you can deploy the resulting EXE to your
users.
'<------- SAMPLE BATCH FILE TO RUN .VBS SCRIPT INSIDE IEXPRESS EXE -->
@ECHO OFF
CLS
cscript %0\..\myscript.vbs //NOLOGO
'<-- END SAMPLE BATCH FILE -->
Notes:
1. %0\..\ --> tell batch file to look for myScript.vbs in same
directory as the batch file
2. When a user runs the myScript.exe package the source files are
extracted to a folder under the users TEMP folder (i.e. C:\Documents
and Settings\%username%\Local Settings\Temp. The package install
command is run (i.e. myScript.bat) and when done this temp folder is
deleted.
Hope this helps.
Steve Parry [MVP] wrote:
> "JAQK" <johnny@tamtam.com> wrote in message
> news:ASdBf.4663$Ez3.3200@trnddc03...
> >I have a .vbs script that I can run from the command line without a
> >problem.
> > (simply using 'cscript script.vbs')
> >
> > I don't know what syntax to use in order to properly create some sort
> > of batch file which I could then run by double-clicking or using the
> > task scheduler.
> >
> > If I just copy and paste the syntax text from the command line window,
> > it will not work in a batch file, so I know I'm doing something wrong.
> >
> > Thanks in advance.
> >
>
> You cannot compile a script because it takes the run-time engine to
> interpret the code.
>
> You can encode the script by way of the Windows Script Encoder, look for
> the encoder on the MS script site.
>
>
http://www.microsoft.com/mind/0899/scriptengine/scriptengine.asp
>
> It's not 100% secure but will keep most users from modifying or viewing
> the code.
>
>
> --
> Steve Parry BA (Hons) MCP MVP
>
>
http://mvp.support.microsoft.com/
>
http://www.gwynfryn.co.uk