我有下面的脚本,它引用了两个文件名,第二个文件名出现在Join(Array())
""
之间,但是我需要使用已经存在的文件夹名称之前在变量中定义,用于在此文件夹中创建一个新文件,并将存储此脚本生成的最终结果:
Option Explicit
Const LOCAL_APPLICATION_DATA = &H1c&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(LOCAL_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
Set colItems = objFolder.Items
Dim sCurDir
Dim sFina
For Each objItem in colItems
If InStr(1, objItem.Name, "Google") > 0 Then
sCurDir = objFolderItem.Path + "\" + objItem.Name + "\Chrome\User Data\Default\"
sFina = "History"
Exit For
End If
Next
Function qq(s) : qq = """" & s & """" : End Function
Const cnHidden = 0
Const cbWait = True
Dim sCmd : sCmd = Join(Array( _
"%comspec%" _
, "/c" _
, "sqlite3.exe" _
, "-csv" _
, qq("..\data\History") _
, qq("SELECT id, url FROM urls LIMIT 5") _
, ">.\urls.csv" _
))
WScript.Echo sCmd
CreateObject("WScript.Shell").Run sCmd, cnHidden, cbWait
WScript.Echo "Done"
然后,如果我尝试用例如">.\urls.csv"
替换""""+sCurDir + "new.csv"""
,则会创建文件。如何解决?
答案 0 :(得分:0)
<强> 解决: 强>
Dim strUser
strUser = CreateObject("WScript.Network").UserName
...
Dim sCmd : sCmd = Join(Array( _
"%comspec%" _
, "/c" _
, "sqlite3.exe" _
, "-csv" _
, qq(sCurDir + sFina) _
, qq("SELECT url FROM urls") _
, ">C:\Users\"+strUser+"\AppData\Local\Google\Chrome\new.csv" _
))