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

Windows Script Encoder - How to decode all files in several folders?!

175 views
Skip to first unread message

Lasse Q

unread,
Nov 13, 2002, 9:10:25 AM11/13/02
to
Hi!
I use windows script encoder to encode my .asp files into
another folder. When I encrypt, I can only encrypt all
files in one specific folder each time. Is it posibble to
make a recusive command in DOS to decrypt all the
subfolders's files in one folder?

(Hope you understand me, i'm Danish)

P.s. Are there any alternatives to Windows Script Encoder
(Maybe a type of Windows Application, and not
a "primitive" DOS program :-) ?)

Michael Harris (MVP)

unread,
Nov 13, 2002, 10:37:15 PM11/13/02
to
Lasse Q wrote:
> Hi!
> I use windows script encoder to encode my .asp files into
> another folder. When I encrypt, I can only encrypt all
> files in one specific folder each time. Is it posibble to
> make a recusive command in DOS to decrypt all the
> subfolders's files in one folder?
>
> (Hope you understand me, i'm Danish)


You have to write your own wrapper script that calls the script encoder
recursively to walk a directory tree. The encoder doesn't have a switch to
trigger recursive processing.

>
> P.s. Are there any alternatives to Windows Script Encoder
> (Maybe a type of Windows Application, and not
> a "primitive" DOS program :-) ?)


None that would create code that the WSH host/script engines would
understand.

You should understand that encoding is not encryption and that it's trivial
to find a 'windows script decoder' on the 'net.

Google Search: "windows script decoder"
http://www.google.com/search?as_epq=windows+script+decoder


--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US


Lasse

unread,
Nov 16, 2002, 6:34:28 PM11/16/02
to
Thank you for you answer.
Okay, I understand that Windows Script Encoder doesn't support this
type of recursive function.
But what is the solution? Does anybody have an answer (or the
solution) ?

I would be very happy.
/Lasse (DK)

You say, that script encoder was not really "encryption", and it was
very easy to hack. That is right, but since I don't have any
alternatives, I'm have to use this program. Also, the encoded files
are only meant to do it hard for "normal" people to change the
settings.

Lasse

unread,
Nov 16, 2002, 6:35:23 PM11/16/02
to

Torgeir Bakken (MVP)

unread,
Nov 18, 2002, 12:41:43 PM11/18/02
to
"Michael Harris (MVP)" wrote:

> Lasse wrote:
> > Thank you for you answer.
> > Okay, I understand that Windows Script Encoder doesn't support this
> > type of recursive function.
> > But what is the solution? Does anybody have an answer (or the
> > solution) ?
> >
>

> You need to write a routine that calls itself recursively. It starts with
> the root folder (the 1st folder with files/subfolders to process). It
> handles the files in that folder and then walks the subfolders and calls
> itself with each one...
>
> Here's a recurcive example that executes the dir command on a folder and
> each of it's subfolders, capturing all of the standard output and displaying
> it at the end. Notice that processFolder calls itself recursively.
>
> set fso = createobject("scripting.filesystemobject")
> set shell = createobject("wscript.shell")
>
> spath = "c:\_temp"
> scapture = "c:\capture.txt"
>
> scmd = "%comspec% /c dir " & chr(34)
> scmd2 = "\*.*" & chr(34) & " >>" & scapture

Just a small note (the OP is Danish): The dir method might give you some
problems in some cases if you have non-Latin characters in the file names, like
the norwegian characters æ,ø and å.


--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway


Michael Harris (MVP)

unread,
Nov 18, 2002, 12:07:50 PM11/18/02
to
Lasse wrote:
> Thank you for you answer.
> Okay, I understand that Windows Script Encoder doesn't support this
> type of recursive function.
> But what is the solution? Does anybody have an answer (or the
> solution) ?
>

You need to write a routine that calls itself recursively. It starts with


the root folder (the 1st folder with files/subfolders to process). It
handles the files in that folder and then walks the subfolders and calls
itself with each one...

Here's a recurcive example that executes the dir command on a folder and
each of it's subfolders, capturing all of the standard output and displaying
it at the end. Notice that processFolder calls itself recursively.

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

spath = "c:\_temp"
scapture = "c:\capture.txt"

scmd = "%comspec% /c dir " & chr(34)
scmd2 = "\*.*" & chr(34) & " >>" & scapture

fso.opentextfile(scapture,2).close

set root = fso.getfolder(spath)

processFolder root

shell.run scapture

sub processFolder(folder)
dim cmd
cmd = scmd & folder.path & scmd2
shell.run cmd,0,true
for each sf in folder.subfolders
processFolder sf '<=== recursive call
next
end sub

Michael Harris (MVP)

unread,
Nov 18, 2002, 3:20:30 PM11/18/02
to
> Just a small note (the OP is Danish): The dir method might give you
> some problems in some cases if you have non-Latin characters in the
> file names, like the norwegian characters æ,ø and å.

True, using DIR was just an example. In the end he wants to drive
screnc.exe.

Lasse

unread,
Nov 28, 2002, 6:54:12 AM11/28/02
to
Thank you all for the answers!
I've now bould a script (called "Encode.VBS"), and I will post it here
so all you guys can use it.
Thanks all!
P.S. The comments are on Danish - sorry!

Encode.vbs
--------------
' dette script vil encode alle asp-filer, og kalde sig selv
' så undermapper automatisk medtages (rekursivt kald)
' der promptes for startmappe
' lange filnavne bruges, hvis de IKKE indeholder blanke tegn

' evt parameter hentes
Set argsUnnamed = WScript.Arguments.Unnamed
MitDir = ""
if argsUnnamed.Count > 0 then
MitDir = argsUnnamed.Item(0)
if not right(MitDir,1) = "\" then MitDir=MitDir & "\"
end if
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
' findes mappen, så encode alle asp-filer, og kopiér alle andre
if fs.folderexists(MitDir) then
' opretter encoded mappetræ inkl evt foregående mapper på samme drev
MitDirEnco = left(MitDir,2) & "\Encoded" & mid(MitDir,3,len(MitDir))
pos = instr(4,MitDirEnco,"\",1)
while pos > 0
if not fs.folderexists(left(MitDirEnco,pos)) then set fs2 =
fs.createfolder(left(MitDirEnco,pos))
pos = instr(pos+1,MitDirEnco,"\",1)
wend
Set folder1 = fs.GetFolder(MitDir)
' encoder asp-filer i mitdir, kopiérer alle andre
For each FileName in folder1.files
FraFil = MitDir & FileName.name
TilFil = MitDirEnco & FileName.name
if right(lcase(FraFil),4)=".asp" then
intReturn = WshShell.Run("cmd /c screnc " & FraFil & " " & TilFil, 7,
FALSE)
else
intReturn = fs.CopyFile(FraFil, TilFil)
end if
next
' finder mapper i folderen MitDir, og kalder sig selv med mappens
fulde sti som parameter
Set SubFolders = folder1.SubFolders
If SubFolders.Count <> 0 Then
for Each SubFolder In SubFolders
if lcase(SubFolder.name) <> "encoded" then
NytDir = SubFolder.Path
if instr(1,NytDir," ",1) then NytDir = SubFolder.ShortPath
intReturn = WshShell.Run("encode.vbs " & NytDir, 7, FALSE)
end if
Next
End If
Set folder1 = nothing
Set SubFolders = nothing
else
' hvis ingen parameter, så promt efter en
if not lcase(MitDir) = "x\" then
NytDir = inputbox("Indtast startmappen eller X for stop: ","Hvor?","")
intReturn = WshShell.Run("encode.vbs " & NytDir, 7, FALSE)
end if
end if
Set WshShell = nothing
Set fs = nothing
-----------------

0 new messages