我想獲取VBScript中當前目錄的子目錄內的文件的路徑。以下似乎不工作?VBScript當前目錄+子目錄?
currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
FileToCopy = currentDirectory & "\test\user.js"
這裏是整個代碼:
Set oFSO = CreateObject("Scripting.FileSystemObject")
strFolder = oFSO.GetParentFolderName(WScript.ScriptFullName)
FileToCopy = oFSO.BuildPath(strFolder, "unproxy\user.js")
''# get AppdataPath
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
AppdataPath = WshSysEnv("APPDATA")
FoxProfilePath = AppdataPath & "\Mozilla\Firefox\Profiles\"
'"# is firefox and user.js present?
if oFSO.FolderExists(FoxProfilePath) AND oFSO.FileExists(FileToCopy) Then
''# copy user.js in all profilefolders to get around those random profile names =)
For Each ProfileFolder In oFSO.GetFolder(FoxProfilePath).Subfolders
oFSO.GetFile(FileToCopy).Copy ProfileFolder & "\" & FileToCopy, True
Next
End If
'"# clean up
Set oFSO = Nothing
Set WshShell = Nothing
Set WshSysEnv = Nothing
你可以詳細說明你的意思是「似乎沒有工作」?你得到一個錯誤或不正確的結果?什麼是您的VBScript腳本的文件名? – Helen 2010-10-19 21:28:12
我沒有得到一個錯誤,似乎沒有發生 - 該文件不復制,因爲我猜測它無法找到user.js文件。 – Romulus 2010-10-19 21:44:01
文件名是copyFile.vbs – Romulus 2010-10-19 21:44:16