closures共享目录中的所有文件

我有一个脚本,执行以下操作

'Create a bat file Set objBatFile = objFS.CreateTextFile("X:\" & strType & "\closeit.bat",True) intExitCode = objBatFile.Write("for /f " & chr(34) & "skip=4 tokens=1" & chr(34) & " %%a in ('net files') do net files %%a /close") objBatFile.Close 'Run the bat file to close all files in the directory intExitCode = objShell.Run("X:\" & strType & "\closeit.bat", intWindowStyle, blnWaitOnReturn) StopStart 'Delete the bat file Set obj = CreateObject("Scripting.FileSystemObject") obj.DeleteFile("X:\" & strType & "\closeit.bat") 'Deletes the file throught the DeleteFile function 

我想知道是否有人知道一种方法来使用VBScriptreplace我用来closures服务器上打开文件的.bat文件命令? 下面为了更好的清晰起见,我想replace下面这行:

 for /f " & chr(34) & "skip=4 tokens=1" & chr(34) & " %%a in ('net files') do net files %%a /close 

执行cmd

 intExitCode = objShell.Run("CMD.EXE /C for /f ""skip=4 tokens=1"" %a in ('net files') do net files %a /close"), blnWaitOnReturn) 

请注意,对于外部批次,变量前需要单个%

你可以用"+Chr(34)+"替换"+Chr(34)+" "" (至少在VBA和VB.NET中)。