sry guys m新編程。我試圖製作一個vbscript來處理從當前位置到系統啓動文件夾的vbs文件。但是m得到錯誤的文件名或數字。但是當我手動給路徑時,它就像一個魅力。我的代碼自我挑選的路徑也是正確的。不能明白是什麼問題。請幫幫我。這是我的代碼。錯誤的文件名或編號:vbs錯誤
Set objShell = Wscript.CreateObject("Wscript.Shell")
strMyPath = objShell.SpecialFolders("Startup")
wscript.echo strPath
wscript.echo strMyPath
'Const strMyPath = "C:\Users\Bilal\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
Const SourceFile = "abc.vbs"
Set fso = CreateObject("Scripting.FileSystemObject")
'Check to see if the file already exists in the destination folder
If fso.FileExists(strMyPath) Then
'Check to see if the file is read-only
If Not fso.GetFile(strMyPath).Attributes And 1 Then
'The file exists and is not read-only. Safe to replace the file.
fso.CopyFile SourceFile, strMyPath, True
Else
'The file exists and is read-only.
'Remove the read-only attribute
fso.GetFile(strMyPath).Attributes = fso.GetFile(strMyPath).Attributes - 1
'Replace the file
fso.CopyFile SourceFile, strMyPath, True
'Reapply the read-only attribute
fso.GetFile(strMyPath).Attributes = fso.GetFile(strMyPath).Attributes + 1
End If
Else
'The file does not exist in the destination folder. Safe to copy file to this folder.
fso.CopyFile SourceFile, myStrPath, True
End If
Set fso = Nothing
哪條線是發生錯誤? – aphoria
最後一個複製語句。文件不存在的情況。 – Bilal
我已經評論了一個const變量語句。如果我使用這種說法,它工作得很好。 – Bilal