进程无法访问该文件,因为其他进程正在使用该文件。代码:80070020,VBScript
当我运行vbscript时,它会显示(在Windows脚本主机中):进程无法访问该文件,因为其他进程正在使用该文件。代码:80070020,VBScript,vbscript,Vbscript,当我运行vbscript时,它会显示(在Windows脚本主机中): C:\Users\admin\Desktop\Test.vbs 线路:34 字符:1 错误:进程无法访问该文件,因为另一进程正在使用该文件 代码:80070020 来源:(空) 我怎样才能解决这个问题?这里还有剧本 Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFSO, objFolder, objShell, objFile Dim strD
C:\Users\admin\Desktop\Test.vbs 线路:34 字符:1 错误:进程无法访问该文件,因为另一进程正在使用该文件 代码:80070020 来源:(空)
我怎样才能解决这个问题?这里还有剧本
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFSO, objFolder, objShell, objFile
Dim strDirectory, strFile
strDirectory = "c:\Folder"
strFile = "\Hidden.bat"
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
End If
set objFolder = nothing
set objFile = nothing
Const fsoForAppend = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("C:\Folder\Hidden.bat", fsoForAppend)
objTextStream.WriteLine "attrib ""Folder"" +s +h"
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """C:\Folder\Hidden.bat"""
Set objShell = Nothing
关闭打开的文本流文件
object.Close
来自帮助
您需要在写入后关闭它,然后再使用它
关闭打开的文本流文件
object.Close
来自帮助
在使用之前,您需要在写入后将其关闭。无需创建任何批处理文件来隐藏文件夹:
Option Explicit
Dim objFSO,objFolder,strDirectory,Command,Result,objShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
strDirectory = "C:\Folder"
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
set objFolder = nothing
Command = "Cmd /c Attrib +s +h "& DblQuote(strDirectory) &""
Set objShell = CreateObject("WScript.Shell")
Result = objShell.Run(Command,0,True)
Set objShell = Nothing
'****************************************************************
Function DblQuote(str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'****************************************************************
不创建任何批处理文件来隐藏文件夹:
Option Explicit
Dim objFSO,objFolder,strDirectory,Command,Result,objShell
Set objFSO = CreateObject("Scripting.FileSystemObject")
strDirectory = "C:\Folder"
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
set objFolder = nothing
Command = "Cmd /c Attrib +s +h "& DblQuote(strDirectory) &""
Set objShell = CreateObject("WScript.Shell")
Result = objShell.Run(Command,0,True)
Set objShell = Nothing
'****************************************************************
Function DblQuote(str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'****************************************************************
你的目标是什么?我猜你想隐藏
c:\folder
?你的目标是什么?我猜你想隐藏c:\folder
?