我想创建一个vbscript,它将从路径中取出文件夹并使用zip.exe将其拆分为4个部分,这样做我在调用zip.exe时出错了。它适用于unzip.exe
明确选项
dim objShell, objFSO, objArgs
dim strPkgFolder, strzip, strUnzip, strTcRoot
set objShell = CreateObject("WScript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")
set objArgs = WScript.Arguments
strTcRoot = "C:\Users\sdeepak6\Desktop\extracted\F025.R22.zip"
strzip ="C:\Users\sdeepak6\Desktop\extracted\zip.exe"
strPkgFolder="C:\Users\sdeepak6\Desktop\new project\F025.R22"
if not objFSO.FileExists(strzip) then
wscript.echo "***ERROR: zip file:" & strzip & " doesn't exist"
WScript.Quit(20005)
end if
wscript.echo "zip utility: " & strzip & " is available..."
if not objFSO.FolderExists(strPkgFolder) then
wscript.echo "***ERROR:" & strPkgFolder & " doesn't exist ..."
WScript.Quit (1)
end if
funcZip strPkgFolder,strTcRoot,strzip
function funcZip(strAppFile, strzipLocation, strzip)
'昏暗的SHELL,FS,strCommand,strFile,intErrReturn
set SHELL = CreateObject("WScript.Shell")
set FS = CreateObject("Scripting.FileSystemObject")
funcZip = True
if not FS.FolderExists(strAppFile) Then
funcZip = False
wscript.echo "Folder: " & strAppFile & " doesn't exist..."
exit function
end if
if not FS.FileExists(strzipLocation) Then
funcZip = False
wscript.echo "File: " & strzipLocation & " doesn't exist..."
exit function
end if
strCommand = Chr(34) & strzip & Chr(34) & " -s 2m -r " & Chr(34) & strzipLocation & Chr(34) & " " & Chr(34) & strAppFile & Chr(34)
wscript.echo "Executing the command: " & strCommand
intErrReturn = 0
intErrReturn = SHELL.Run(strCommand, 0, True)
if intErrReturn <> 0 then
funcZip = False
wscript.echo "***WARNING: Zip command execution is failed with error code: " & intErrReturn
end if
Set FS = Nothing
Set SHELL = Nothing
end function