Content Type
Profiles
Forums
Events
Everything posted by gunsmokingman
-
I wrote this Demo script for you to try. You will have to add the folder name you want to check in this spot in the script. Dim Chk :Chk = Array("Folder1", "Folder2") Save As Demo_RecursiveFolder.vbs Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles For Run Time Dim Arg, Dir, Obj, Ts, Txt, Var '-> Array To Hold Folder Name To Check For Dim Chk :Chk = Array("Folder1", "Folder2") '-> Arg To Check If Any Matching Folder Found Arg = False '-> Script Report Txt = Fso.GetFolder(".").Path & "\Report.txt" Set Ts = Fso.CreateTextFile(Txt) Ts.WriteLine " Scan Time : " & Time() Ts.WriteLine " Scan Date : " & Date() '-> Start Recursive From Script Current Location '-> Recursive(Fso.GetFolder(".")) Or Add A Full Path '-> EG Recursive(Fso.GetFolder("C:\SOME\FOLDER\PATH")) Recursive(Fso.GetFolder(".")) '-> End Of The Script Report Ts.WriteLine Var Ts.Close '-> Arg Check If Match Found If Arg = True Then '-> Open Report To Read CreateObject("Wscript.Shell").Run("Notepad " & Chr(34) & _ Txt & Chr(34)),1,True '-> To Keep Or Delete If MsgBox("Did You Want To Keep This File?",4132,"Keep Or Delete") = 7 Then Fso.DeleteFile(Txt),True End If Else '-> No Match Found MsgBox "Could Not Find Any Matching Folder In This Location" & vbCrLf & _ Fso.GetFolder(".").Path, 4128,"No Match Found" Fso.DeleteFile(Txt),True End If '-> Recursive Threw All Sub Folders Function Recursive(Folder) '-> Loop Threw Check Folder And Check For A Match For Each Obj In Chk '-> Check For Folder Name Case Insensitive If InStr(1,Folder.Path,Obj,1) Then Arg = True Var = Var & vbcrlf & _ "----------------------------------" & _ vbCrLf & "Match Found : " & Folder.Path & vbCrLf & _ "----------------------------------" & vbCrLf End If Next '-> Loop Threw Sub Folders For Each Dir In Folder.subFolders Recursive(Dir) Next End Function Change Name From Demo_RecursiveFolder.vbs.txt to Demo_RecursiveFolder.vbs to make active Demo_RecursiveFolder.vbs.txt
-
If you where to use VBS scripting then a script to do what you want would look like this Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Arg, AdobePath, AdobeFile, C1, Key, Obj, Var AdobePath = "C:\Applications\CS4\Updates\" Arg = " --mode=silent" AdobeFile = Array( _ AdobePath & "acrobat9pro-EFG\AcroProStdUpd910_T1T2_incr.msp <> /qn", _ AdobePath & "acrobat9pro-EFG\AcrobatUpd912_all_incr.msp <> /qn", _ AdobePath & "acrobat9pro-EFG\AcrobatUpd920_all_incr.msp <> /qn", _ AdobePath & "Fireworks-10.0.3-AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "Photoshop_11.0.2_mul_AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "AdobeDrive_1.0.1_AdobeUpdate_2\Setup.exe <> " & Arg, _ AdobePath & "AdobeExtensionManager-2.1-mul-AdobeUpdate2\Setup.exe <> " & Arg, _ AdobePath & "AdobeCameraRaw-5.7-mul-AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "AdobeOutputModule-2.1-mul-AdobeUpdate_2\Setup.exe <> " & Arg, _ AdobePath & "AdobeVersionCue4All_4.0.1_AdobeUpdate_2\Setup.exe <> " & Arg, _ AdobePath & "AME_All_CS4.2_mul_AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "DeviceCentral_2.1.1_mul_AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "Flash-10.0.2-AdobeUpdate\Setup.exe <> " & Arg, _ AdobePath & "Soundbooth-2.0.1-786\Setup.exe <> " & Arg) C1 = 1 Key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" Act.RegWrite Key & "040\", "Installing Adobe CS4 Updates", "REG_SZ" For Each Obj In AdobeFile Var = Split(Obj," <> ") Act.RegWrite Key & "040\" & C1, Chr(34) & Var(0) & Chr(34) & Var(1), "REG_SZ" C1 = C1 + 1 Next
-
Here is your script updated with 3 Sources Folders Ans 3 Destination Folders I do not know if this will work I only made a guess at this script. Save As MultipleMove.vbs Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Source Folders Dim Obj, SPath, Var '-> Source And Destination Array SPath = Array( _ "e:\backup\serverA = e:\serverA", _ "e:\backup\serverB = e:\serverB", _ "e:\backup\serverC = e:\serverC") '-> Loop Threw Source And Destination Array For Each Obj In SPath '-> Split The Array Item To Get Source And Destination '-> EG "e:\backup\serverA = e:\serverA" '-> Source = e:\backup\serverA = Var(0) '-> Destination = e:\serverA = Var(1) Var = Split(Obj," = ") Sub ShowSubFolders(Var(0)) Next '-> Recursive Threw All Sub Folders Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders call CheckFolder(subfolder,Var(1)) ShowSubFolders Subfolder Next End Sub '-> Move Folders Sub CheckFolder(objCurrentFolder, MoveHere) Const OverwriteExisting = True Dim objFile For Each objFile In objCurrentFolder.Files FileName = objFile '-> Destination Folde objFSO.MoveFile FileName, MoveHere Next End Sub Rename MultipleMove.vbs.txt to MultipleMove.vbs to make active Updated Fixed 3 typo Errors MultipleMove.vbs.txt
-
Here is another way of doing what you want using vbs scripting I have used a only a couple of your examples in the script below. Template 1, for only a single item '-> Start Cut And Paste Template 1 '-> FireFox 3.64 Var = "z:\Firefox\Firefox364.exe" If Fso.FileExists(Var) Then Act.RegWrite Key & "010\", "Installing FireFox 3.64", "REG_SZ" Act.RegWrite Key & "010\1", Var & " -ms", "REG_SZ" Else Rpt = Var End If '-> End Cut And Paste Template 1 Template 2, for only a multiple items '-> Start Cut And Paste Template 2 '-> Itunes-Quicktime C1 = 1 Str = Array( _ "z:\Itunes64Setup\AppleApplicationSupport.msi", _ "z:\Itunes64Setup\AppleMobileDeviceSupport64.msi", _ "z:\Itunes64Setup\AppleSoftwareUpdate.msi ", _ "z:\Itunes64Setup\Quicktime.msi", _ "z:\Itunes64Setup\Bonjour64.msi", _ "z:\Itunes64Setup\iTunes64.msi") If Fso.FileExists(Str(0)) Then Act.RegWrite Key & "050\", "Installing Itunes-Quicktime", "REG_SZ" For Each Col In Str Act.RegWrite Key & "050\" & C1, Col & " /qn", "REG_SZ" C1 = C1 + 1 Next Else For Each Col In Str Rpt = Rpt & vbCrLf & Col Next End If '-> End Cut And Paste Template 2 Save As RunOnce_Demo.vbs '-> Objects For Run Time Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles For Runtime Dim C1, Chk, Col, Cmp, ComputerNames, Obj, Rpt, Str Cmp =Act.ExpandEnvironmentStrings("%ComputerName%") '-> Array For Computer Names ComputerNames = Array("2F26","2F24","2F20","2F18") '-> Loop Threw Array For Each Obj In ComputerNames '-> Code Here For Matching Computers If InStr(1,Cmp, Obj,1) Then AddUser() RunOnce() '-> Report Any Missing Apps If Len(Rpt) > 3 Then MsgBox vbTab & "Error Missing App" & vbCrLf & _ "These application path where not found, so " & vbCrLf & _ "they where not added to the RunOnceEx list." & vbCrLf & _ Rpt ,4128,"Error Missing Apps" End If WScript.Quit(0) Else Chk = False End If Next '-> Add User Function AddUser() Act.Run( _ "NET USE Z: \\192.168.1.216\Installations Mypassword /USER:Robw"),0,True End Function '-> RunOnce Function RunOnce() Dim Key, Var Key = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" Act.Run("rundll32.exe iernonce.dll,RunOnceExProcess"),1,True Act.RegWrite Key & "TITLE", "Test Post Image Configurations", "REG_SZ" '-> Start Cut And Paste Template 1 '-> FireFox 3.64 Var = "z:\Firefox\Firefox364.exe" If Fso.FileExists(Var) Then Act.RegWrite Key & "010\", "Installing FireFox 3.64", "REG_SZ" Act.RegWrite Key & "010\1", Var & " -ms", "REG_SZ" Else Rpt = Var End If '-> End Cut And Paste Template 1 '-> Start Cut And Paste Template 1 '-> Java 6 Update 20 Var = "z:\Java6U20\jre-6u20-windows-i586-s.exe" If Fso.FileExists(Var) Then Act.RegWrite Key & "015\", "Installing Java 6 Update 20", "REG_SZ" Act.RegWrite Key & "015\1", Var & " /s /v /qn ADDLOCAL=ALL" & _ " IEXPLORER=1 MOZILLA=1 SYSTRAY=0 JAVAUPDATE=0 REBOOT=Suppress", "REG_SZ" Else Rpt = Rpt & vbCrLf & Var End If '-> End Cut And Paste Template 1 '-> Start Cut And Paste Template 2 '-> Flash Player C1 = 1 Str = Array( _ "z:\FlashPlayer\install_flash_player_10_active_x.msi", _ "z:\FlashPlayer\install_flash_player_10_plugin.msi") If Fso.FileExists(Str(0)) Then Act.RegWrite Key & "020\", "Installing Flash Player", "REG_SZ" For Each Col In Str Act.RegWrite Key & "020\" & C1, Col & " /qn", "REG_SZ" C1 = C1 + 1 Next Else For Each Col In Str Rpt = Rpt & vbCrLf & Col Next End If '-> End Cut And Paste Template 2 '-> Start Cut And Paste Template 1 '-> Shockwave Player Var = "z:\ShockwavePlayer\sw_lic_full_installer.msi" If Fso.FileExists(Var) Then Act.RegWrite Key & "025\", "Installing Shockwave Player", "REG_SZ" Act.RegWrite Key & "025\1", Var & " /qn", "REG_SZ" Else Rpt = Rpt & vbCrLf & Var End If '-> End Cut And Paste Template 1 '-> Start Cut And Paste Template 2 '-> Itunes-Quicktime C1 = 1 Str = Array( _ "z:\Itunes64Setup\AppleApplicationSupport.msi", _ "z:\Itunes64Setup\AppleMobileDeviceSupport64.msi", _ "z:\Itunes64Setup\AppleSoftwareUpdate.msi ", _ "z:\Itunes64Setup\Quicktime.msi", _ "z:\Itunes64Setup\Bonjour64.msi", _ "z:\Itunes64Setup\iTunes64.msi") If Fso.FileExists(Str(0)) Then Act.RegWrite Key & "050\", "Installing Itunes-Quicktime", "REG_SZ" For Each Col In Str Act.RegWrite Key & "050\" & C1, Col & " /qn", "REG_SZ" C1 = C1 + 1 Next Else For Each Col In Str Rpt = Rpt & vbCrLf & Col Next End If '-> End Cut And Paste Template 2 End Function '-> End Of Script If No Matches Found If Chk = False Then MsgBox "This computer, " & Cmp & _ " does not match any on the list",4128,"Not A Listed Computer" End If Change from RunOnce_Demo.vbs.txt to RunOnce_Demo.vbs to make active RunOnce_Demo.vbs.txt
-
Batch file question
gunsmokingman replied to jlester3's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here a VBS script 1:\ Run Csript 2:\ Ask if you want to continue or quit 3:\ If Continue will attempt to delete all files in the listed Dir Array 4:\ Show The Total Amount Of Files Deleted And The Amont Deleted In Mb Or Kb CleanUp.vbs '-> Objects To Use uring Runtime Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Pathway Varibles Dim Win :Win = Act.ExpandEnvironmentStrings("%Windir%") Dim UsD :UsD = Act.ExpandEnvironmentStrings("%UserProfile%") '-> Array For Directories Dim Dir :Dir = Array( _ Win & "\prefetch", _ Win & "\temp", _ UsD & "\Appdata\Local\Temp",_ "c:\temp", _ UsD & "\Local Settings\Temporary Internet Files", _ UsD & "\Local Settings\Temp") '-> Varibles To Be Used During Runtime Dim C1, C2, File, Folder, Lne, Obj, Reply Lne = " -------------------------------------------------------------- " '-> To Make Sure This Runs In Cscript Only If InStr(1,WScript.FullName,"cscript",1) Then YesNo() ElseIf InStr(1,WScript.FullName,"wscript",1) Then MsgBox vbTab & "Error Wrong Scripting Engine" & vbCrLf & _ "To Use This Script It Must Be Run Under Cscript.exe" & vbCrLf & _ "Right Click This Script And Select Command Prompt" & vbCrLf & _ "Option, To Open This Script Correctly",4128,"Error Wrong Engine" End If '-> Yes Or No Function Function YesNo() '-> Show List Of Folder To Delete Files WScript.StdOut.WriteLine " Directories To Clean Up" & vbCrLf & Lne For Each Obj In Dir If Fso.FolderExists(Obj) Then WScript.StdOut.WriteLine " " & Obj End If Next WScript.StdOut.WriteBlankLines 1 Do While Len(Reply) < 5 WScript.StdOut.WriteLine Lne WScript.StdOut.WriteLine " Do You Want To Continue With Deleting All" WScript.StdOut.WriteLine " Above Listed Directories Files. This Script" WScript.StdOut.WriteLine " Will Attempt To Delete All Files In All Sub" WScript.StdOut.WriteLine " Directories. Type Yes To Continue And No To" WScript.StdOut.WriteLine " Exit And Do Nothing" WScript.StdOut.WriteLine Lne WScript.StdOut.WriteBlankLines 1 Reply = Wscript.StdIn.ReadLine '-> User Confirms If InStr(1,Reply, "yes",1) Then For Each Obj In Dir If Fso.FolderExists(Obj) Then Recursive Fso.GetFolder(Obj) End If Next '-> Converts Number To Either Mb Or Kb If C2 > 1048576 Then C2 = FormatNumber(C2 / 1048576,2) C2 = C2 & " Mb" Else C2 = FormatNumber(C2 / 1024,2) C2 = C2 & " Kb" End If '-> End Of Script WScript.StdOut.WriteLine " Total Files Deleted : " & C1 WScript.StdOut.WriteLine " Total Sizes Deleted : " & C2 WScript.StdOut.WriteLine " Press Enter To Exit" Do While WScript.StdIn.AtEndOfLine WScript.Quit() Loop '-> User Cancel ElseIf InStr(1,Reply, "no",1) Then WScript.Quit End If Loop End Function '-> Loop Threw All Sub Folders Function Recursive(Loc) WScript.StdOut.WriteLine Lne & vbCrLf & _ " Procesing Folder : " & Loc.Name & vbCrLf & lne On Error Resume Next For Each File In Loc.Files C1 = C1 + 1 C2 = Int(C2) + Int(File.Size) WScript.StdOut.WriteLine File.Name Fso.DeleteFile(File.Path),True Next For Each Folder In Loc.subFolders Recursive Folder Next End Function Rename CleanUp.vbs.txt to CleanUp.vbs to make active CleanUp.vbs.txt -
First of all, from the code you posted APPDATA does nothing other then waste a line. It is not used at all in the below batch script. So there was no point in adding it to my VBS script. @echo off SET APPDATA=N:/data/ Start "Test" "N:\Test.jar" If you can not provide full script then do not complain when someone takes the time to do what you request, when you are the one at fault for providing less then the full script.
-
Here I try this VBS script, I have added a check to make sure the file exists. Save as JarCheck.vbs Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Check To Make Sure File Exists If Fso.FileExists("N:\Test.jar") Then Act.Run("Test N:\Test.jar"),1,True Else MsgBox "Error Missing File N:\Test.jar",4128,"Error Missing File" End if
-
WMI during unattended install
gunsmokingman replied to Sardius's topic in Unattended Windows 2000/XP/2003
Read this Link it might help you -
Need script to detect SSD
gunsmokingman replied to randalldale's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I do not known if this script will help but give it a try. This list drive letter and drive type FsoDrives.vbs Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Obj, Drv '-> To Run In Csript Only If InStr(1,WScript.FullName,"cscript",1) Then ListDrives() '-> End Of Script WScript.StdOut.WriteLine "Press Enter To Close Window" Do While WScript.StdIn.AtEndOfLine WScript.Quit() Loop ElseIf InStr(1,WScript.FullName,"wscript",1) Then MsgBox _ "Wrong Scripting Engine Error. To Use This Script." & vbCrLf & _ "You Must Right Click The Script And Select The " & vbCrLf & _ "Cmd Prompt As The Engine To Run The Script.",4128,"Error Wrong Engine" End If '-> List Drive Letter And Drive Type Function ListDrives() For Each Obj In Fso.Drives Select Case Obj.DriveType Case 1 :Drv = "Removable" Case 2 :Drv = "Fixed" Case 3 :Drv = "Network" Case 4 :Drv = "CdDvd" Case 5 :Drv = "RAMDisk" Case Else :Drv = "Unknown" End Select WScript.StdOut.WriteLine Obj.DriveLetter & " - " & Drv Next WScript.StdOut.WriteBlankLines 1 End Function Wmi Script that list drive letter and drive type WmiDrives.vbs Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") Dim Drv, Obj '-> To Run In Csript Only If InStr(1,WScript.FullName,"cscript",1) Then ListDrives() '-> End Of Script WScript.StdOut.WriteLine "Press Enter To Close Window" Do While WScript.StdIn.AtEndOfLine WScript.Quit() Loop ElseIf InStr(1,WScript.FullName,"wscript",1) Then MsgBox _ "Wrong Scripting Engine Error. To Use This Script." & vbCrLf & _ "You Must Right Click The Script And Select The " & vbCrLf & _ "Cmd Prompt As The Engine To Run The Script.",4128,"Error Wrong Engine" End If '-> List Drive Letter And Drive Type Function ListDrives() For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_LogicalDisk") Select Case Obj.DriveType Case 0 :Drv = "Unknown" Case 1 :Drv = "No Root Directory" Case 2 :Drv = "Removable Disk" Case 3 :Drv = "Local Disk" Case 4 :Drv = "Network Drive" Case 5 :Drv = "Optical Drive" Case 6 :Drv = "Ram Disk" End Select WScript.StdOut.WriteLine Chr(160) & Obj.DeviceID & " - " & Drv Next WScript.StdOut.WriteBlankLines 1 End Function Rename FsoDrives.vbs.txt to FsoDrives.vbs to make active Rename WmiDrives.vbs.txt to WmiDrives.vbs to make active FsoDrives.vbs.txt WmiDrives.vbs.txt -
echo %date%
gunsmokingman replied to net_user's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here is a Cmd Script that makes a VBS script to make the date formate EG Month Name, Day Name , Date, Year Save As MyDate.cmd @Echo Off CLS Mode 55, 5 Color F9 Title Custom Date Demo Set VBS=MyDate.vbs Echo Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") > %VBS% Echo Dim Cmd, Ts >> %VBS% Echo Cmd = "Date.cmd" >> %VBS% Echo Set Ts = Fso.CreateTextFile(Cmd) >> %VBS% Echo Ts.WriteLine "Set MyDate="^&MonthName(Month(Now)) ^& ", " ^& _ >> %VBS% Echo WeekdayName(Weekday(Now)) ^& _ >> %VBS% Echo ", " ^& Day(Now) ^& ", " ^& Year(Now) >> %VBS% Echo Ts.Close >> %VBS% %VBS% call Date.cmd Del %VBS% Del Date.cmd Echo. Echo MyDate=%MyDate% pause -
You could try this VBS script. 1:\ Checks For File Exists 2:\ If Missing Error Mesage 3:\ If Exists It Should Run The File. '-> Path To File Dim File :File="N:\Shared\TOandPGI\TOCounter.vbs" '-> Check Before We Run If CreateObject("Scripting.FileSystemObject").FileExists(File) Then CreateObject("Wscript.Shell").Run(Chr(34) & File & Chr(34)),1,True Else MsgBox "Error Can Not Find This File" & vbCrLf & _ File,4128,"Error Missing File" End If
-
First of all you have posted no code what so ever, just a outline of what you want done. Two there seems to be some confusion as to what forum this is,.As I stated in the above post of mine, this is for programming and coding only not 7Customer,Vlite or whatever else. Three since I am a Mod I do not like the tone that seems to be appearing between you and Moonchilde If you, aviv00 can not post more along this line I would not waste my time writing any code for this myself, other may want to.
-
English is obviously not your first language. 7Customer does NOT have the ability to shrink WinSxS YET. You can HELP by creating XML files which tell 7Customizer what to delete. My point is, why make a new program when 7Customizer already has the foundation to do so? All YOU need to do is help tell it what to delete. What language do you normally speak? Maybe someone can help translate. Perhaps you should learn this is a programming section and not a 7Customer section. Also maybe you should learn how to be more polite, which would not matter if someone had posted some code. If SOMETHING Then DO SOME THING Else SOME OTHER ACTION End If If (SOMETHING==SOMETHING) {SOME ACTION} else {ANOTHER ACTION} If no one is going ro post any code, or any refrences to code langauges I will be closing this thread.
-
Change File Name Case
gunsmokingman replied to PROBLEMCHYLD's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Change this Line errResult = Obj.Rename(Path & "\" & LCase(Name)) To This To Make Uppercase errResult = Obj.Rename(Path & "\" & UCase(Name)) -
Change File Name Case
gunsmokingman replied to PROBLEMCHYLD's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here is a script I wrote up it does 1:\ Runs in Cscript 2:\ Can have Manual Input 3:\ Drag And Drop Folder 4:\ uses Wmi to rename files 5:\ Save Results Rename ReNameToLowerCase.vbs.txt to ReNameToLowerCase.vbs to make active ReNameToLowerCase.vbs.txt