(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 :-) ?)
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
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 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
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
True, using DIR was just an example. In the end he wants to drive
screnc.exe.
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
-----------------