Board logo

标题: [原创]js与vbs互转的wsf脚本 [打印本页]

作者: s11ss     时间: 2008-2-1 14:12    标题: [原创]js与vbs互转的wsf脚本
<!-- js<->vbs	{Author:s11ss|From:www.cn-dos.net|Date:2008-2-1} -->

<job>

<script language=vbscript>
With WScript.Arguments
If .Count<1 Then .ShowUsage:WScript.Quit
For i=1 To .Count
s=s&vbCrLf&vbCrLf&i&"."&T(.Item(i-1))
Next
End With
WScript.Echo s
Function T(file)
Select Case Right(file,4)
Case ".vbs",".vbe" ext="js"
Case ".jse" ext="vbs"
Case Else If Right(file,3)=".js" Then ext="vbs"
End Select
If ext="" Then T="It's not a vbs or js file: "&file:Exit Function
Set fso=CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(file) Then T="It doesn't exist: "&file:Exit Function
str=getResource(ext)
Set orgf=fso.OpenTextFile(file)
If ext="vbs" Then
While Not orgf.AtEndOfStream
aline=orgf.ReadLine
str=str&vbCrLf&"';"&aline
Wend
Else
str=str&vbCrLf&orgf.ReadAll&vbCrLf&";*/"
End If
orgf.Close
Set newf=fso.CreateTextFile(file&"."&ext,True)
newf.Write str
newf.Close
Set fso=Nothing:Set orgf=Nothing:Set newf=Nothing
T="Created: "&file&"."&ext
End Function
</script>

















<!-- usage and resource to use -->
<runtime>
<description>
vbs2js or js2vbs
(Other files won't be changed.)
</description>
<unnamed
name="filename"
helpstring="The file(s) to be changed."
many="true"
required="1"
/>
</runtime>

<resource id=js>
<!























]>
</resource>

<resource id=vbs>
<!


















]>
</resource>

</job>

作者: slore     时间: 2008-2-1 14:48
我晕~还以为是……

原来是。。。生成的VBS在自己下面有JS的源码,自己读自己然后过滤写到TEMP去。。。再调用。。


不过WSF文件还是头一次看。。。开始还以为是flash呢。
这个倒是挺新的……

作者: s11ss     时间: 2008-2-1 18:57
Originally posted by slore at 2008-2-1 02:48 PM:
我晕~还以为是……

原来是。。。生成的VBS在自己下面有JS的源码,自己读自己然后过滤写到TEMP去。。。再调用。。

我想,通过把vbs和js的语句表达严格对应来实现互相转换恐怕是行不通的吧?