Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script Encoder

295 views
Skip to first unread message

RA

unread,
Feb 12, 2004, 10:31:05 PM2/12/04
to
I have downloaded and installed the Encoder from

http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

The documentation provided lists the program as being accessible from the C prompt however the command line C:\screnc inputfile.sct outputfile.sct lists the program as " 'srenc' is not recognized as an internal or external command,etc... "

What am I doing wrong?

Michael Harris \(MVP\)

unread,
Feb 12, 2004, 11:32:02 PM2/12/04
to

You need to open the command prompt on the folder where screnc.exe is
installed (or add that folder to the PATH environment variable). You'll
need to fully qualify the path to the script.

You don't really need scrence.exe to encode scripts (assuming you have a
relatively current version of WSH installed).

Here's a working encoder script that I use as a drag/drop target to encode
scripts...


'=== ScriptEncoder.vbs ===

filename = wscript.arguments(0)

set shell = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")

defExt = "." & lcase(fso.getExtensionname(filename))
defLanguage = ""
cFlags = 0
'Note: cFlags has meaning only for ASP pages...
'
'cFlags = 0 '0x0 adds <%@ LANGUAGE=VBScript.Encode%> directive
'cFlags = 1 '0x1 adds <%@ LANGUAGE=defLanguage.Encode%> directive
'cFlags = 2 '0x2 suppresses <%@ LANGUAGE="..."%> directive

if defExt = ".vbs" _
or defExt = ".js" _
or defExt = ".wsf" _
or defExt = ".asp" then
'OK...
else
msgbox "Not a .vbs, .js, .wsf, or .asp file..."
wscript.quit
end if

if defExt = ".vbs" then
outfile = replace(filename,".vbs",".vbe")
defLanguage = "vbscript"
elseif defExt = ".js" then
outfile = replace(filename,".js",".jse")
defLanguage = "jscript"
elseif defExt = ".asp" then
outfile = replace(filename,".asp",".encode.asp")
defLanguage = "vbscript"
else
outfile = replace(filename,".wsf",".encode.ws")
defLanguage = "vbscript"
defExt = "html"
end if

set Encoder = createobject("Scripting.Encoder")
with fso.opentextfile(filename)
code = .read(fso.getfile(filename).size)
end with

on error resume next
encodedscript = Encoder.EncodeScriptFile(_
defExt, code, clng(cFlags), defLanguage)

If err = 0 then
On error GoTo 0
fso.opentextfile(outfile,2,true).write encodedscript
msgbox "Encoded script written to: " & outfile
else
msgbox "Encoding error: 0x" & hex(err.number) & vbcrlf _
& "Description: " & err.description,vbSystemModal
On error GoTo 0
end if

--
Michael Harris
Microsoft.MVP.Scripting

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp

TechNet Script Center Sample Scripts
http://www.microsoft.com/technet/scriptcenter/default.asp
Download in HTML Help format (searchable and indexed)
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Ray at <%=sLocation%> [MVP]

unread,
Feb 12, 2004, 11:44:59 PM2/12/04
to
I think what it probably meant is that it's a command line tool. It
installs in (by default) C:\Program Files\Windows Script Encoder, so CD to
that directory at your command prompt or enter the full path along with
screnc. If you are trying to execute a file that is not in your current
directory at the command prompt, it must exist in one of the paths in your
%path% environment variable.

Just CD to the directory in which you installed screnc.exe.

--

Ray at home
Microsoft ASP MVP


"RA" <answer(remove-parenthesis)@robin-ann.com> wrote in message
news:9AF7EE6D-370F-466A...@microsoft.com...

R A

unread,
Feb 13, 2004, 2:31:29 PM2/13/04
to

I would like your drag and drop script. I however am quite new to this
and wonder how to execute the method.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

R A

unread,
Feb 13, 2004, 6:39:15 PM2/13/04
to
Thank you for pointing out the proper directory. I had watch it install
to system32 and could not understand why I could not find it.

I copied the program to C and it works beautiful.

Many thanks.

Robin-Ann

Michael Harris \(MVP\)

unread,
Feb 13, 2004, 9:47:07 PM2/13/04
to
> I would like your drag and drop script. I however am quite new to this
> and wonder how to execute the method.


Just copy the script code I posted and paste it into your own script file.
I named mine ScriptEncoder.vbs.

Create a shortcut to ScriptEncoder.vbs and put the shortcut on the desktop.
To sign a script, just drag/drop it onto that shortcut.

Or you can put the shortcut in the SendTo folder

(C:\Documents and Settings\username\SendTo)

This is a hidden folder, so you may not be able to see it unless you change
your folder options to show hidden files/folders.

Once the shortcut is in the SendTo folder, you can encode a script by right
clicking on the script and then choosing your shortcut from the Send To
context menu.

Marco Maier Said

unread,
Feb 14, 2004, 9:30:00 AM2/14/04
to

> Or you can put the shortcut in the SendTo folder
>
> (C:\Documents and Settings\username\SendTo)
>
> This is a hidden folder, so you may not be able to see it unless you change
> your folder options to show hidden files/folders.

Simple:

start-run-SendTo

(without modifying folder options)

--
Marco

R A

unread,
Feb 16, 2004, 11:11:36 AM2/16/04
to

Dear Mr. Harris

Thank you for the great script :) I figured out how to make it work in
my config.

I really appreciate your attention. I am so very happy now.

Sincerely,
Robin Ann

0 new messages