Option Explicit
' REL. 2009-03-30
'-- PARAMETERS --------------------------------------------------------------------
const zipperName = "\TUGZip\TUGZip.exe"
const zipperPara = "e"
'----------------------------------------------------------------------------------
'-- CONSTANTS ---------------------------------------------------------------------
const runWindowStyleMin = 2
const runWindowStyleMax = 3
const runWindowStyleActivate = 5
const runWaitOnReturn = True ' lo script deve aspettare che l'istruzione termini
' prima di continuare?
'----------------------------------------------------------------------------------
dim fso, wsh
set fso = CreateObject("Scripting.FileSystemObject")
set wsh = CreateObject("WScript.Shell")
' get script parameters
dim argFile
argFile = WScript.Arguments(0)
' get curent zip_filename
dim curFile
curFile = fso.GetBaseName(argFile)
' get filename dir
dim curDir
curDir = fso.GetParentFolderName(argFile)
if Right(curDir, 1) <> "\" then curDir = curDir & "\"
' create new directory using dir+filename(w/o extension)
dim newDir
newDir = curDir & curFile
if not fso.FolderExists(newDir) then
fso.CreateFolder(newDir)
end if
' finds programs directory
dim progDir
progDir = wsh.Environment("PROCESS").Item("ProgramFiles")
' shell launch unzipper
dim wCmd
wCmd = ""
wCmd = wCmd & Chr(34) & progDir & zipperName & Chr(34) & " "
wCmd = wCmd & Chr(34) & zipperPara & Chr(34) & " "
wCmd = wCmd & Chr(34) & argFile & Chr(34) & " "
wCmd = wCmd & Chr(34) & newDir & Chr(34)
wsh.run wCmd, runWindowStyleMax, runWaitOnReturn
' -- move the folder up one level ---------------------------------------------
Dim wrongDir
Dim rightDir
wrongDir = newDir & "\" & curFile
rightDir = curDir & curFile
Const tempDir = "tmp.boso"
If fso.FolderExists(wrongDir) Then
'MsgBox wrongDir & vbCrLf & rightDir
fso.MoveFolder wrongDir, tempDir
fso.DeleteFolder rightDir, True
fso.MoveFolder curDir & tempDir, rightDir
End If
' -----------------------------------------------------------------------------
' open folder
wsh.Run "explorer " & Chr(34) & newDir & Chr(34), 5, runWaitOnReturn
set wsh = nothing
set fso = nothing
14 October 2009
BosoEstractHere.vbs
Programma per estrarre e aprire un file compresso: