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
复制代码
|