Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait for a 7z (7Zip) Command to Finish and run it on silent 1

Status
Not open for further replies.

Mharugha

Instructor
Oct 16, 2015
3
0
0
PT
Good Day,

I'm doing my first steps on vbscript and my first job was to develop a small script to Backup and Compress some SQL databases.

Unfortunately I'm stuck on 2 issues:
1. I can't run the 7Zip Archive command on Silent (The command windows is always popping up indicating the extraction percentage)
2. How can I force VBScript to wait for 7Zip Archive command to finish. As can you see after this procedure i need to delete the .bak databases and keep only the compressed file on folder. I'm using a 'Wscript.Sleep' instruction but this is not perfect because the time to archive can differ from Backup to Backup.

***** CODE BEGIN *****
Set objShell = wscript.createObject("wscript.shell")
InstallPath = """C:\Program Files\7-Zip\7z.exe"""
vTarget = """D:\NTBCKPS\DBS\NT_DBS.7z"""
vSource = """D:\NTBCKPS\DBS\*.bak"""
null1 = """> nul"""

objShell.Run InstallPath & " a -t7z -mx9 -r -y " & vTarget & " " & vSource & " " & null1
REM objShell.Run InstallPath & " a -t7z -mx9 -r -y " & vTarget & " " & vSource

'objShell.Run InstallPath & t & vTarget
'MsgBox "Espera"

Wscript.Sleep 20000


Set objApagar = CreateObject("Scripting.FileSystemObject")
Set pasta = objApagar.getFolder("D:\NTBCKPS\DBS")
'If objApagar.FileExists("D:\NTBCKPS\DBS\*model.bak") Then
If pasta.files.Count <> 0 then
objApagar.DeleteFile("D:\NTBCKPS\DBS\*.bak")
End If

***** CODE END *****
 
Thank you for your help.
Parameter 0 and True helped me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top