Jump to content

"Quotes" Question about CMD Batch


Recommended Posts

 Directory di C:\teststructure

10/11/2011 20:23 <DIR> .
10/11/2011 20:23 <DIR> ..
08/11/2011 20:51 45.569 batch.cmd
10/11/2011 20:20 <DIR> Dir
10/11/2011 20:20 <DIR> Tools
1 File 45.569 byte

Directory di C:\teststructure\Dir

10/11/2011 20:20 <DIR> .
10/11/2011 20:20 <DIR> ..
10/11/2011 20:20 <DIR> Temp
0 File 0 byte

Directory di C:\teststructure\Dir\Temp

10/11/2011 20:20 <DIR> .
10/11/2011 20:20 <DIR> ..
0 File 0 byte

Directory di C:\teststructure\Tools

10/11/2011 20:20 <DIR> .
10/11/2011 20:20 <DIR> ..
18/04/2011 19:54 941.568 7z.dll
18/04/2011 19:34 168.448 7z.exe
2 File 1.110.016 byte

In the "Dir" directory i put the updates, now is empty, while in the "Temp" subdir i'll extract the zipped updates found in "Dir".

Edited by Caml Light
Link to comment
Share on other sites


sometimes i decide to zip them to save space when i put them in my fullest USB pen drive :)

So, this is a condition to consider for the batch.

Well, for the record not really, no.

It is a condition you imposed.

The issue I see is that if you have EITHER:

  • ONLY non-zipped files

OR:

  • ONLY zipped files

THEN the file name sort sequential processing MAY make sense, BUT if you have a "mixed set of files" the order in which they are processed may well become a BIG problem. :ph34r:

In such a setup I would rather use a verified sorted list instead.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

Just to satisfy my curiosity, how much space do you gain by compressing already compressed updates (please post the total space used by updates before and after) ?

right consideration :), only using x86 post-SP1 updates for Windows 7 compressed with 7-Zip (.7z ext) 272MB -> 259MB (13MB earned), only for ONE O.S.! not bad (at least for me, clear :lol:)

Coming back in topic, have you others suggestions for me after having seen my batch structure? Thanks

Link to comment
Share on other sites

And, AGAIN, can you post an example of a POPULATED by the actual fles directory structure? :realmad:

Can you READ my previous post? :rolleyes:

Do you understand that until now what you propose is to process first all 7-zip compressed files (or ZIPped, you posted CONTRASTING info on this) and later all "normal" SFX .exe files (or the other way round first all the .exe's and then all the .7z's) and that this may not be a smart move as it may alter the proper order in which the updates should be installed? :unsure:

jaclaz

Link to comment
Share on other sites

Here is what I understand, could be wrong

1:\ He has uncompressed updates in one folder

2:\ He has compressed updates in another

3:\ He want to extract compressed ones then install all

Here is a VBS script only tested to run without errors without

testing these Install Updates or Extract Updates

Item In The Script You Need To Change Or Check

Zip Path For 7z. This assume the script location is the Parent Directory With a

folder called Tools EG USB_DriveLetter:\Tools\


Dim Zip :Zip = Act.CurrentDirectory & "\Tools\"

Extract

Change From


'-> UnComment To Make Active Run 7z Extract
' Act.Run(Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & Ext & " -y")

Change To


'-> UnComment To Make Active Run 7z Extract
Act.Run(Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & Ext & " -y")

Install Updates

Change From


'-> UnComment To Make Active Run Install
' Act.Run(c34 & Obj & c34 & " /quiet /norestart"),1,True

Change To


'-> UnComment To Make Active Run Install
Act.Run(c34 & Obj & c34 & " /quiet /norestart"),1,True

Save As ExtInstallKb.vbs this script will run and Produce a text file without changes


''-> Object For Run Time
Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
'-> Varibles Used At Run Time
Dim c34 :c34 = Chr(34)
Dim Zip :Zip = Act.CurrentDirectory & "\Tools\"
Dim Ext :Ext = Act.ExpandEnvironmentStrings("%tmp%\KbInstall")
Dim Rpt :Rpt = Act.ExpandEnvironmentStrings("%tmp%\KbInstall\KbRpt.txt")
'-> Varibles For Loop And Text Stream
Dim Col, Chk, Obj, Ts
'-> Create Temp Folder
If Not Fso.FolderExists(Ext) Then Fso.CreateFolder(Ext)
'-> Open Text Report
Set Ts = Fso.CreateTextFile(Rpt)
Ts.WriteLine " Script Date : " & Year(Now) & "-" & _
MonthName(Month(Now),False) & "-" & _
WeekdayName(Weekday(Now),False) & "," & Day(Date)
Ts.WriteLine " Script Time : " & Hour(Time) & ":" & _
Minute(Time) & ":" & Second(Time) & vbCrLf
'-> Recursive(Fso.GetFolder("."))
' Uses Script Location As Parent Folder To Start Recursive Search
' Of All Folders And There Sub Folders
Recursive(Fso.GetFolder("."))
If Chk = True Then
Ts.WriteLine vbCrLf & " Installing Updates In : " & Fso.GetFolder(Ext).Path
'-> Loop Threw Updates In Temp Folder
For Each Obj In Fso.GetFolder(Ext).Files
If Right(InStr(1,Obj.Name,"msu",1),3) Or _
Right(InStr(1,Obj.Name,"ms1",1),3) Or _
Right(InStr(1,Obj.Name,"exe",1),3) Then
Ts.WriteLine " Install Update : " & Obj.Path
'-> Remove Only For Demo Show KB Unstall Command
Ts.WriteLine "Act.Run(" & c34 & Obj & c34 & " /quiet /norestart" & "),1,True"
'-> UnComment To Make Active
' Act.Run(c34 & Obj & c34 & " /quiet /norestart"),1,True
End If
Next
Else
Ts.WriteLine vbCrLf & " Nothing was extracted or installed."
End If
'-> Close The Report
Ts.Close()
'-> Open The Report To Read
Act.Run(c34 & Rpt & c34),1,True
'-> Ask To Keep Or Delete Report
If MsgBox("Would You Like To Keep This Report",4132, _
"Keep Or Delete") = 6 Then
Fso.CopyFile Rpt, Act.SpecialFolders("Desktop") & "\KbRpt.txt",True
End If
'-> Delete The Temp Folder
If Fso.FolderExists(Ext) Then Fso.DeleteFolder(Ext)
'-> List All Folders And Files
Function Recursive(Folder)
Ts.WriteLine vbCrLf & " Searching Folder: " & Folder
For Each Obj In Folder.Files
'-> Filter Out Script From Being Process
If Not InStr(1,Obj.Path,WScript.ScriptFullName,1) Then
'-> Filter Out Updates By Name
If InStr(1,Obj.Name,"kb7",1) Or InStr(1,Obj.Name,"kb8",1) Or _
InStr(1,Obj.Name,"kb9",1) Then
If Right(InStr(1,Obj.Name,"msu",1),3) Then
Chk = True
Ts.WriteLine " Confirm Update : " & Obj.Name
Fso.CopyFile Obj, Ext & "\", True
ElseIf Right(InStr(1,Obj.Name,"zip",1),3) Then
Ts.WriteLine " Confirm Zip KB : " & Obj
Chk = True
'-> Remove Only For Demo Show 7z File For Extract To Where It Extracted To
Ts.WriteLine "Act.Run(" & Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & c34 & Ext & c34 & " -y),1,true"
'-> UnComment To Make Active
' Act.Run(Zip & "7z x " & c34 & Obj.Path & c34 & " -o" & Ext & " -y")
End If
End If
End If
Next
'Ts.WriteLine
For Each Col In Folder.SubFolders
Recursive(Col)
Next
End Function

Rename ExtInstallKb.vbs.txt from to ExtInstallKb.vbs to make active script.

This will run and Produce a text file without changes or errors

ExtInstallKb.vbs.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...