标题: vbs循环产生的参数怎么传递
[打印本页]
作者: yywd
时间: 2008-6-3 15:42
标题: 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
这个只传递一次就完了
作者: joyn
时间: 2008-6-3 15:56
Originally posted by yywd at 2008-6-3 15:42:
vbs循环产生的参数怎么传递
Set objFSO = CreateObject("Scripting.FileSystemObject")
这里没必要两次引用吧
作者: yywd
时间: 2008-6-3 17:01
这里是没必要两次引用, 但是问题不在这里呀
作者: joyn
时间: 2008-6-3 20:36
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\11.txt", 1)
Set Wshshell = WScript.CreateObject ("wscript.shell")
strFolder = "d:\1\"
Do While True
If 1 Then
pathstring=objfile.ReadLine
CreatLin (pathstring)
If Err.Number <> 0 Then
WScript.Echo "#"&Err.Number&Space (5)&"Shift"
Err.Clear
Exit Do
End If
End If
Loop
sub CreatLin (x)
Set oShellLink = WshShell.CreateShortcut(strFolder & objFSO.GetBaseName(x) & ".lnk")
oShellLink.TargetPath = objfso.GetParentFolderName (x)
oShellLink.WindowStyle = 1
oShellLink.WorkingDirectory = objFSO.GetParentFolderName(filename)
oShellLink.Save
End Sub
Set objfso = Nothing
Set wshshell = nothing
作者: yywd
时间: 2008-6-7 21:30
有些小问题, 不过方法很好, 我学会了, 谢谢您的帮助