想知道是否有人愿意提供帮助
是否可以创建一个脚本,列出文件夹中以特定名称开头的所有文件,然后将文件名输出到文本文件,然后根据输出的文件名创建注册表项值?
就vbscript而言,到目前为止,我有以下内容(部分内容),但不能:
Dim fso Dim ObjFolder Dim ObjOutFile Dim ObjFiles Dim ObjFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set ObjFolder = fso.GetFolder("C:\JetInfo")
Set ObjOutFile = fso.CreateTextFile("C:\WindowsFiles.txt")
Set ObjFiles = ObjFolder.Files
For Each ObjFile In ObjFiles
ObjOutFile.WriteLine(ObjFile.Name & String(50 - Len(ObjFile.Name), " "))
Next
ObjOutFile.Close
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\NewSignature", "INPUT FILE NAME HERE", "REG_EXPAND_SZ"
答案 0 :(得分:1)
以特定字符串开头的输出文件名:
str = "foobar"
For Each f In fso.GetFolder("C:\JetInfo").Files
If LCase(Left(f.Name, Len(str))) = LCase(str) Then
WScript.Echo f.Name
End If
Next
包含特定字符串的输出文件名:
str = "foobar"
For Each f In fso.GetFolder("C:\JetInfo").Files
If InStr(LCase(f.Name), str) > 0 Then
WScript.Echo f.Name
End If
Next
将文件名写入注册表:
Set f = fso.GetFile("C:\path\to\some.file")
WshShell.RegWrite "HKCU\Software\Microsoft\Office\14.0\Common\NewSignature" _
, Chr(34) & Replace(f.Path, "\", "\\") & Chr(34), "REG_EXPAND_SZ"
至于你的第三个问题:你想从文件中创建什么值?一次又一次地覆盖相同的值是毫无意义的。