BrandonS_Mil Posted February 6, 2006 Share Posted February 6, 2006 I am trying to make a script that will look for specific programs on the computer; then say if it passes by verifying the programs it finds againt a list.I try but i am getting nowhere.... I am useing scriptomatic 2 from Microsoft. I hope this is in the right section.... Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 7, 2006 Share Posted February 7, 2006 (edited) Here try this VBS script. It uses a WMI querry to search for MP3 and WMA file types.This has a list of about 20 songs that do not get added to the HTA that this makes. strComputer = "."Dim Act, Fso, Ts, CT, DT : CT = 0 : DT = 0 Dim Ext, FName, PName, Mp3Rpt,WmaRpt, S_5, V, Wma,Mp3 : Wma = 0 : Mp3 = 0Dim HtaMp3, HtaWma, Uname, HtaL1, L1Hta, HtaL2, L2HtaS_5 = Space(5) : V = vbCrLf Set Act = CreateObject("Wscript.Shell")Set Fso = CreateObject("Scripting.FileSystemObject")UName = Act.ExpandEnvironmentStrings("%UserName%") Dim U_Desk : U_Desk = Act.SpecialFolders.Item("Desktop")Dim SD : SD = Act.ExpandEnvironmentStrings("%SystemDrive%") Seek_MP3_WMA Function BuildTheHta '''' ADD THE SYTLE AND BODY TO HTA Ts.WriteLine S_5 & "<HTML><HEAD><TITLE>" & Uname & ", Music Collection</TITLE><STYLE>" Ts.WriteLine S_5 & "Body.Normal" Ts.WriteLine S_5 & "{ font:12.75pt Poor Richard;color:#808080;filter:progid:DXImageTransform.Microsoft.Gradient" Ts.WriteLine S_5 & "(GradientType=0,StartColorStr='#dedad4',EndColorStr='#cac6c0');}" Ts.WriteLine S_5 & "td.Bar1" Ts.WriteLine S_5 & "{ font:9.75pt Poor Richard;color:#000080;filter:progid:DXImageTransform.Microsoft.Gradient" Ts.WriteLine S_5 & "(GradientType=0, StartColorStr='#5e9ab9',EndColorStr='#eeeeee');}" Ts.WriteLine S_5 & ".Bttn1" Ts.WriteLine S_5 & "{ font:10.75pt;font-family:Poor Richard;font-weight:Italic;line-height:110%;color:#edeced;" Ts.WriteLine S_5 & "(background-color : #6CA2E3;filter:progid:DXImageTransform.Microsoft.Gradient}" Ts.WriteLine S_5 & "(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');width:71;height:25;}" Ts.WriteLine S_5 & "{ font:10.75pt Poor Richard;color:#000080;filter:progid:DXImageTransform.Microsoft.Gradient" Ts.WriteLine S_5 & "(GradientType=0, StartColorStr='#5e9ab9',EndColorStr='#eeeeee');}" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "</STYLE>" Ts.WriteLine S_5 & "<script> window.resizeTo (775,475), window.moveTo (450,275);</SCRIPT>" Ts.WriteLine S_5 & "<script language=""vbscript"">" Ts.WriteLine S_5 & "Dim Act, Fso, UName" Ts.WriteLine S_5 & "Set Act = CreateObject(""Wscript.shell"")" Ts.WriteLine S_5 & "Set Fso = CreateObject(""Scripting.FileSystemObject"")" Ts.WriteLine S_5 & "UName = Act.ExpandEnvironmentStrings(""%UserName%"") " Ts.WriteLine S_5 & "Function Window_Onload" Ts.WriteLine S_5 & "Label1.InnerHtml= UName & "", Music Files""" Ts.WriteLine S_5 & "End Function " Ts.WriteLine S_5 & "" Ts.WriteLine S_5 & "</SCRIPT>" Ts.WriteLine S_5 & "<CENTER><BODY Class=""Normal""><Table>" Ts.WriteLine S_5 & "<SPAN Id=""Label1""> </SPAN>" Exit Function End Function Function Seek_MP3_WMA '''' WMI QUERRY START HERE Set Ts = Fso.OpenTextFile(U_Desk & "\MusicFileList.hta",2,True) BuildTheHta Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2") Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile Where Extension = 'MP3' OR Extension = 'WMA'") For Each objFile in colFiles CT = CT + 1 : DT = DT + 1 Ext = objFile.Extension : FName = objFile.FileName : PName = objFile.Name : FCnt = "File Counter : " If "mp3" = Ext Then If "demo" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "0006076836202.01.01.001[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "thekillerssomebodytoldmedanceremix[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "what%20ive%20been%20looking%20for[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "teddy-%20for%20you%20i%20will[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "you%20know%20what%20they%20do%20to%20guys%20like%20us%20in%20prison[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "0005008613227.01.01.008[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "were%20all%20in%20this%20together[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "0004400641072.01.01.007[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "sf192965-01-01-02[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "american folk" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "classic rock" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "hearts and flowers" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "swing" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else Hta_Mp3 '''' FUNCTION ADDS TO THE HTA End If End If End If End If End If End If End If End If End If End If End If End If End If End If End If '''''''''''''''''''''''' '''''''''''''''''''''''' If "wma" = Ext Then If "Beethoven's Symphony No. 9 (Scherzo)" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "New Stories (Highway Blues)" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "title" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else If "blank[1]" = FName Then '''' DOES NOT GET ADDED TO THE HTA On Error Resume Next Else Hta_Wma '''' FUNCTION ADDS TO THE HTA End If End If End If End If End If Next '''' ADD TOTAL MP3 FILE COUNT Ts.WriteLine "</TABLE><TABLE><TD>Amount Of MP3 File On The Computer " & Mp3 & "</TD></TABLE><TABLE>" Ts.WriteLine L1Hta '''' ADD ALL THE INFO COLLECT IN THE Function Hta_Mp3 '''' ADD TOTAL WMA FILE COUNT Ts.WriteLine "</TABLE><TABLE><TD>Amount Of WMA File On The Computer " & Wma & "</TD></TABLE><TABLE>" Ts.WriteLine L2Hta '''' ADD ALL THE INFO COLLECT IN THE Function Hta_Wma Ts.Close Exit Function End Function Function Hta_Mp3 Mp3 = Mp3 + 1 HtaL1 = (S_5 & "<script language=""vbscript"">" & V & " Function MP3_" & DT &_ V & S_5 & "Act.Run(chr(34) & """ & PName & """ & chr(34))" &_ V & S_5 & "Window.Alert ""File Name : " & FName & """& vbcrlf & ""File Location : ""&vbcrlf&"""&PName&"""" &_ V & S_5 & " End Function </SCRIPT>" &_ V & S_5 & "<TABLE Border=""2""><TD Class=""Bar1"" width=""725""> " &_ V & S_5 & "<INPUT Type=""Button"" Class=""Bttn1"" language=""vbscript"" OnClick=""MP3_" & DT & """ Value=""Play"">" &_ V & S_5 & " " & UCase(FName & "." & Ext) & "</TD></TABLE>") L1Hta = L1Hta & vbCrLf & HtaL1 '''' COLLECT AND STORES ALL THE INFORMATION FOR THE HTA OUTPUT End Function Function Hta_Wma Wma = Wma + 1 HtaL2 = (S_5 & "<script language=""vbscript""> Function WMA_" & DT &_ V & S_5 & "Act.Run(chr(34) & """ & PName & """ & chr(34))" &_ V & S_5 & "Window.Alert ""File Name : " & FName & """& vbcrlf & ""File Location : ""&vbcrlf&"""&PName&"""" &_ V & S_5 & " End Function </SCRIPT>" &_ V & S_5 & "<TABLE Border=""2""><TD Class=""Bar1"" width=""725""> " &_ V & S_5 & "<INPUT Type=""Button"" Class=""Bttn1"" language=""vbscript"" OnClick=""WMA_" & DT & """ Value=""Play"">" &_ V & S_5 & " " & UCase(FName & "." & Ext) & "</TD></TABLE>") L2Hta = L2Hta & vbCrLf & HtaL2 '''' COLLECT AND STORES ALL THE INFORMATION FOR THE HTA OUTPUT End Function Act.Run(Chr(34) & U_Desk & "\MusicFileList.hta" & Chr(34)) '''' RUNS THE HTA AFTER IT BEEN MADE WScript.Sleep 700 On Error Resume Next '''' DELETES THE SCRIPT FROM SYSTEMDRIVE Fso.DeleteFile(SD & "\GsmMkMusicHta.vbs") I have included a sfx file of the above script, it also has the same script but without theexcluded file list. These files will be deleted if they are on %Systemdrive% so extract themto your desktop. Edited February 22, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now