- ·上一篇文章:IPSeccmd简单说明
- ·下一篇文章:Timediff函数 显示两个时间点的差值
- ·百度中搜索更多的关于“将BAT转换为JS运行的批处理程序”相关内容
- ·谷歌中搜索更多的关于“将BAT转换为JS运行的批处理程序”相关内容
- ******申明******
- 本站文章内容有部分为收录网络中其他网友内容,DOS资源站不保证所有的代码都适合你使用。
- 由于编辑匆忙,有可能造成某些脚本文件出现丢失代码或代码无法运行的情况,请网友根据情况自行修改。
- 如果能将出错部分反馈给我,那就更好了。
将BAT转换为JS运行的批处理程序
@echo off %bat2js {s11ss,www.cmdos.net,2008-1-29}%
if not exist "%~f1" echo Usage:&echo "%~n0" source [destination] [/h]&pause&goto :eof
set f2="%~dpn1.js"
set h=1
if "%2" neq "" if "%2" equ "/h" (set h=0) else (if exist "%2\" (set f2="%~dpn2\%~n1.js") else (set f2="%~f2"))
if "%3" equ "/h" set h=0
set n=2
for /f "usebackq" %%a in ("%~f0") do if "%%a" equ ":js" (goto :w) else (set/a n+=1)
:w
>%f2% more +%n% <"%~f0"
>>%f2% echo WshShell.Run("cmd /c"+batPath+arg+"&@del "+batPath,%h%)
>>%f2% echo /*;
>>%f2% more "%~f1"
>>%f2% echo ;*/
goto :eof
:js
var WshShell=new ActiveXObject("WScript.Shell")
var fso=new ActiveXObject("Scripting.FileSystemObject")
var self=fso.OpenTextFile(WScript.ScriptFullName)
var batPath=WshShell.ExpandEnvironmentStrings("%tmp%")+"\\t1.29.bat"
var bat=fso.CreateTextFile(batPath,true)
var found=false
var str=""
while (!self.AtEndOfStream) {
var aline=self.ReadLine()
if (found)
{if (aline!=unescape("%3b")+unescape("%2a")+unescape("%2f")) str=str+aline+"\r\n"}
else
if (aline==unescape("%2f")+unescape("%2a")+unescape("%3b")) found=true
}
bat.Write(str)
bat.Close()
self.Close()
var arg=""
for(var i=0;i<WScript.Arguments.Count();i++) arg=arg+" "+WScript.Arguments(i)


