标题: VBS循环产生的参数怎么传递 [打印本页]
作者: yywd 时间: 2008-6-3 15:30 标题: VBS循环产生的参数怎么传递
vbs循环产生的参数怎么传递
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\1\0.txt", 1)
set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "d:\1\"
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
filename = strLine
Set objFile = objFSO.GetFile(filename)
set oShellLink = WshShell.CreateShortcut(strFolder & objFSO.GetBaseName(filename) & ".lnk")
oShellLink.TargetPath = objFile
oShellLink.WindowStyle = 1
oShellLink.WorkingDirectory = objFSO.GetParentFolderName(filename)
oShellLink.Save
Loop
objFile.Close
这个只传递一次就完了
作者: breakan 时间: 2008-8-10 21:47
能说清楚点儿么?你要干什么?
作者: huahua0919 时间: 2008-8-17 11:44
Do while objFile.AtEndOfStream <> true
作者: zqz0012005 时间: 2008-9-20 17:51
Set objFile = objFSO.GetFile(filename)
这一句有问题,对象实例重名,会将开始的Set objFile = objFSO.OpenTextFile("d:\1\0.txt", 1)替换,导致第2次循环时objFile.AtEndOfStream出现错误
而且这一句似乎没有必要(不知道你的代码是不是只有这么多)
要创建很多个快捷方式,最好使用过程- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.OpenTextFile("d:\1\0.txt", 1)
- set WshShell = WScript.CreateObject("WScript.Shell")
- strFolder = "d:\1\"
- Do Until objFile.AtEndOfStream
- makelink RePlace(objFile.ReadLine,"""","")
- Loop
- objFile.Close
-
- Sub makelink(filename)
- Set f = objFSO.GetFile(filename) '似乎没有必要
- set oShellLink = WshShell.CreateShortcut(strFolder & objFSO.GetBaseName(filename) & ".lnk")
- oShellLink.TargetPath = f '此处直接用filename即可
- oShellLink.WindowStyle = 1
- oShellLink.WorkingDirectory = objFSO.GetParentFolderName(filename)
- oShellLink.Save
- End Sub
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |