中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-16 09:11
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 求cscript的shell代码改进 查看 1,118 回复 9
楼 主 求cscript的shell代码改进 发表于 2007-06-07 21:57 ·  中国 湖北 武汉 电信
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
关于下面的脚本,大家给点建议吧,怎么改进才好
比如说,好象不能cls啊,有谁能帮我加个类似lcls清屏的功能好吗
host = WScript.FullName
hostexe = lcase(mid(host, InstrRev(host, "\")+1))
if not hostexe = "cscript.exe" Then
set wshshell = CreateObject("WScript.Shell")
wshshell.run "CSCRIPT.EXE """ & WScript.ScriptFullName & """"
WScript.Quit
end If

set input = WScript.StdIn
set output = WScript.StdOut

output.Write "> "
do until input.atEndOfStream

line = input.ReadLine
if lcase(line)="exit" then
exit do
else
line = Replace(line, "?", "output.WriteLine")
ExecuteIt line
output.Write "> "
end if
loop
sub ExecuteIt(command)
on error resume Next
ExecuteGlobal command
if not err.Number=0 Then
output.WriteLine "Error: " & err.description
err.clear
end if
end sub


[ Last edited by wert123 on 2007-6-16 at 03:00 PM ]
2 发表于 2007-06-10 11:26 ·  中国 湖北 武汉 电信
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
有谁帮我改改啊
3 发表于 2007-06-10 12:21 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
UID 79003
性别 男
状态 离线
这个脚本写的不错嘛。。。




那cls的时候可以输出N个空行,把显示的推上去=。=
不然重运行下脚本……

我不知道有类似cls的用法。。。。
4 发表于 2007-06-11 11:20 ·  中国 湖北 武汉 教育网
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
Originally posted by slore at 2007-6-10 12:21 PM:
这个脚本写的不错嘛。。。




那cls的时候可以输出N个空行,把显示的推上去=。=
不然重运行下脚本……

我不知道有类似cls的用法。。。。


我不知道谁写的,这本书的作者我忘了啊
就是象cmd下的cls一样的效果啊,vbs是没有,只要效果一样
clx,cl123,clslore都可以的,说明白点,就是用一个操作产生一种清屏效果的方法.
5 发表于 2007-06-11 13:45 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
UID 79003
性别 男
状态 离线
host = WScript.FullName
hostexe = LCase(Mid(host, InstrRev(host, "\") + 1))
Set wshshell = CreateObject("WScript.Shell")
If Not hostexe = "cscript.exe" Then
wshshell.run "CSCRIPT.EXE """ & WScript.ScriptFullName & """"
WScript.Quit
End If

Set input = WScript.StdIn
Set output = WScript.StdOut

output.Write "> "
Do Until input.atEndOfStream

line = input.ReadLine
If LCase(line) = "exit" Then
Exit Do
ElseIf LCase(line) = "cls" Then '这个是重载的……不过效果像,但是
'不像CMD下可以支持之前输入的东西
wshshell.run "CSCRIPT.EXE """ & WScript.ScriptFullName & """"
WScript.Quit
Else
line = Replace(line, "?", "output.WriteLine")
ExecuteIt line
output.Write "> "
End If
Loop
Sub ExecuteIt(command)
on Error Resume Next
ExecuteGlobal command
If Not Err.Number = 0 Then
output.WriteLine "Error: " & Err.description
Err.clear
End If
End Sub
6 发表于 2007-06-14 20:06 ·  中国 湖北 武汉 电信
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
非常感谢啊,不过再次运行后窗口出现在不同位置,视觉上好像感觉不够好
在该窗口中按cls后往上推30行,能帮我这样写个吗?
7 发表于 2007-06-14 20:11 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
UID 79003
性别 男
状态 离线
有个什么blankline好象……
8 发表于 2007-06-14 20:39 ·  中国 湖北 武汉 电信
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
Originally posted by slore at 2007-6-14 08:11 PM:
有个什么blankline好象……

好象什么啊,关键时候怎么掉链子呢
9 发表于 2007-06-14 21:39 ·  中国 陕西 西安 电信
铂金会员
★★★★
积分 5,212
发帖 2,478
注册 2007-02-08 23:39
UID 79003
性别 男
状态 离线
你怎么为什么不用google把链子连起来?

host = WScript.FullName
hostexe = LCase(Mid(host, InstrRev(host, "\") + 1))
Set wshshell = CreateObject("WScript.Shell")
If Not hostexe = "cscript.exe" Then
wshshell.run "CSCRIPT.EXE """ & WScript.ScriptFullName & """"
WScript.Quit
End If

Set input = WScript.StdIn
Set output = WScript.StdOut

output.Write "> "
Do Until input.atEndOfStream

line = input.ReadLine
If LCase(line) = "exit" Then
Exit Do
ElseIf LCase(line) = "cls" Then
output.WriteBlankLines 30
output.Write "> "
Else
line = Replace(line, "?", "output.WriteLine")
ExecuteIt line
output.Write "> "
End If
Loop
Sub ExecuteIt(command)
on Error Resume Next
ExecuteGlobal command
If Not Err.Number = 0 Then
output.WriteLine "Error: " & Err.description
Err.clear
End If
End Sub
10 发表于 2007-06-16 14:58 ·  中国 湖北 武汉 电信
中级用户
★★
积分 301
发帖 135
注册 2007-05-15 16:49
UID 88615
性别 男
状态 离线
谢谢你啊,slore大师技术好,又热心,辛苦了啊!
也许要写个.dll或者.ocx文件吧,
我不会再问像这样的问题了:store你帮我写个vbs把局域网的电停了

[ Last edited by wert123 on 2007-6-16 at 03:44 PM ]
论坛跳转: