Copy the content of info1.txt (simple text file) to the clipboard nircmd.exe clipboard readfile "c:\My Files\info1.txt"
复制代码
- '用vbs实现随机读取文件的一行内容的脚本
- '发布:dxy 字体:[增加 减小] 类型:转载
- '复制代码 代码如下:
- randomize
- set fso = CreateObject("Scripting.Filesystemobject")
- set a = CreateObject("Scripting.Dictionary")
- set file = fso.OpenTextFile("a.txt")
- do while file.AtendofStream<>true
- m = m + 1
- a.add m,file.readline
- loop
- file.close
- h=int(rnd * m)
- msgbox "第" & h & "行: " & a(h) ,4096,"随机内容"
复制代码
- REM 用vbs遍历文件并随机显示的脚本
- REM 发布:dxy 字体:[增加 减小] 类型:转载
- set ws=createobject("wscript.shell")
- set fso=createobject("scripting.filesystemobject")
- set folder=fso.getfolder(ws.currentdirectory)
- set files=folder.files
- for each file in files
- d=d & file.name & ","
- next
- Randomize
- Do Until D = ""
- s = Split(D, ",")
- M = UBound(s)
- h = Int(Rnd * M)
- N = s(h)
- sn = sn & N & vbcr
- D = Replace( D, N & ",", "",1,1)
- Loop
- MsgBox sn
将剪切板中内容添加到文本info1.txt中
nircmd.exe clipboard addfile "c:\My Files\info1.txt"
randomize
set fso = CreateObject("Scripting.Filesystemobject")
set a = CreateObject("Scripting.Dictionary")
set file = fso.OpenTextFile("C:\Documents and Settings\Administrator\桌面\3.txt")
do while file.AtendofStream<>true
m = m + 1
a.add m,file.readline
loop
file.close
h=int(rnd * m)
WshShell.run "G:\PowerPro_4.9n7\配置文件夹\nircmd.exe clipboard set " & chr(34) & a(h) & chr(34)
脚本 : C:\Documents and Settings\Administrator\桌面\新建 文本.vbs
行: 13
字符: 2
错误: 缺少对象: 'WshShell'
代码: 800A01A8
源: Microsoft VBScript 运行时错误
randomize
set fso = CreateObject("Scripting.Filesystemobject")
set a = CreateObject("Scripting.Dictionary")
set file = fso.OpenTextFile("C:\Documents and Settings\Administrator\桌面\3.txt")
do while file.AtendofStream<>true
m = m + 1
a.add m,file.readline
loop
file.close
h=int(rnd * m)
CreateObject("WScript.Shell").Run "G:\PowerPro_4.9n7\配置文件夹\nircmd.exe clipboard set " & chr(34) & a(h) & chr(34)
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |