CODE: [Copy to clipboard]
If WScript.Arguments.Count <> 1 Then WScript.Quit
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSS = CreateObject("Wscript.Shell")
F = WScript.Arguments(0)
If FSO.FileExists(F) Then
FileExt = UCase(FSO.GetExtensionName(F))
If FileExt = "CAB" Or Right(FileExt,1) = "_" Then WScript.Quit
FilePath = FSO.GetParentFolderName(F)
FileFName = FSO.GetFileName(F)
FileBName = FSO.GetBaseName(F)
TEMP = WSS.ExpandEnvironmentStrings("%TEMP%")
If FSO.FileExists(TEMP & "\modifype.tmp") Then FSO.DeleteFile TEMP & "\modifype.tmp",True
MpeErr = WSS.Run("MODIFYPE.EXE " & UCase(FSO.GetFile(F).ShortPath) & " -c",0,True)
If MpeErr <> 0 Then
If FSO.FileExists(TEMP & "\modifype.tmp") Then
If FSO.FileExists(F) Then FSO.DeleteFile F,True
FSO.MoveFile TEMP & "\modifype.tmp",F
End If
Call MsgBox("MODIFYPE can't patch " & Chr(34) & FileFName & Chr(34),vbOKOnly,"Error")
WScript.Quit
End If
If FileExt = "" Then
FC = UCase(FilePath & "\" & FileBName & "._")
Else
FC = UCase(FilePath & "\" & FileBName & "." & Mid(FileExt,1,2) & "_")
End If
CabErr = WSS.Run("CABARC.EXE -m LZX:21 N " & Chr(34) & FC & Chr(34) & " " & Chr(34) & F & Chr(34),1,True)
If CabErr <> 0 Then
Call MsgBox("CABARC can't compress file " & Chr(34) & FileFName & Chr(34),vbOKOnly,"Error")
Else
If FSO.FileExists(F) Then FSO.DeleteFile F,True
End If
End If
If FSO.FolderExists(F) Then
WSS.CurrentDirectory = F
CabErr = WSS.Run("CABARC.EXE -m LZX:21 -p -r N " & Chr(34) & UCase(F) & ".CAB" & Chr(34) & " *.*",1,True)
If CabErr <> 0 Then
Call MsgBox("CABARC can't compress folder " & Chr(34) & FSO.GetFolder(F).Name & Chr(34),vbOKOnly,"Error")
End If
End If
==============================================CODE: [Copy to clipboard]
If WScript.Arguments.Count <> 1 Then WScript.Quit
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSS = CreateObject("Wscript.Shell")
F = WScript.Arguments(0)
If FSO.FileExists(F) Then
FileExt = UCase(FSO.GetExtensionName(F))
FilePFolder = FSO.GetFile(F).ParentFolder
FileFName = FSO.GetFileName(F)
If FileExt = "CAB" Then
FileBName = FSO.GetBaseName(F)
NewFolder = FilePFolder & "\" & FileBName
If Not FSO.FolderExists(NewFolder) Then FSO.CreateFolder(NewFolder)
WSS.CurrentDirectory = NewFolder
CabErr = WSS.Run("CABARC.EXE -o -p X " & Chr(34) & F & Chr(34),1,True)
If FSO.GetFolder(NewFolder).Size = 0 Then CabErr = 1
If CabErr <> 0 Then
WSS.CurrentDirectory = FSO.GetFolder(NewFolder).ParentFolder
FSO.DeleteFolder NewFolder,True
Call MsgBox("CABARC can't decompress file " & Chr(34) & FileFName & Chr(34),vbOKOnly,"Error")
End If
WScript.Quit
End If
If Right(FileExt,1) = "_" Then
WSS.CurrentDirectory = FilePFolder
CabErr = WSS.Run("CABARC.EXE X " & Chr(34) & F & Chr(34),1,True)
If CabErr <> 0 Then
Call MsgBox("CABARC can't decompress file " & Chr(34) & FileFName & Chr(34),vbOKOnly,"Error")
Else
If FSO.FileExists(F) Then FSO.DeleteFile F,True
End If
WScript.Quit
End If
End If
===============================================