Jump to content

gunsmokingman

Super Moderator
  • Posts

    2,296
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Canada

Everything posted by gunsmokingman

  1. The threads are similir enough for me to issue a warning for double posting, you should of ask for any further questions in the original thread.
  2. Why are you double posting the same basic question when I provided a VBS script for you in this Thread.
  3. Correct Way Dim DelPath :DelPath = Act.ExpandEnvironmentStrings Yours The Wrong way Dim DelPath :DelPath = Act .ExpandEnvironmentStrings You have a space where there is suppose to none. That is what your error is about. The period should be character 28 folowed by the Expand at 29
  4. Try this vbs script that will read contents of text file and write them to a new text file. Demo_Recursive_List_Text.vbs '-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.Dim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Arg, Col, Obj, Ts, TxtTxt = Act.SpecialFolders("Desktop") & "\List_Text_Contents.txt"'-> Makes The Folder Where Script Resides Parent Folder For RecursiveList(Fso.GetFolder("."))'-> Add Path Fso.GetFolder("SomeDrive\FolderName")Function List(Folder)'-> List Files In FolderFor Each Col In Folder.FilesIf LCase(Right(Col,3)) = "txt" ThenSet Ts = Fso.OpenTextFile(Col)Arg = Ts.ReadAllTs.CloseIf Fso.FileExists(Txt) ThenSet Ts = Fso.OpenTextFile(Txt,8)Ts.WriteLine Col.Name & vbCrLfTs.WriteLine ArgTs.CloseElseSet Ts = Fso.CreateTextFile(Txt)Ts.WriteLine Col.Name & vbCrLfTs.WriteLine ArgTs.CloseEnd IfEnd IfArg = ""Next'-> Loop Threw All Sub FoldersFor Each Obj In Folder.SubFoldersList(Obj)NextEnd Function
  5. Test this on Windows 7 x64 VBS script using Admin Cmd Promt This image show using %ProgramFiles% varibles as missing and not able to delete the folder This image show confirm and deletes folder using %SystemDrive%\Program Files (x86)\ to make the path to the folder for delete.
  6. It would be more helpful if you posted any code that you have written.
  7. Here is a Link to a vbs script that I wrote. With a lttile modification it will do what you want.
  8. Here is a VBS script that goes threw the parent folder and all of the sub folders and list files. This will produce a text file with the missing folder path, the move command. It will not make any folders or move any files.
  9. 1:\ Are you trying to remove %ProgramFiles(x86)%\Test\(CF3 Support)\ and all it sub folders and files? 2:\ Or are you trying to remove from %ProgramFiles(x86)%\Test\(CF3 Support)\ all the files and leave the folder empty? Here is a VBS script that I tested to remove a folder in the Programfiles Test Path = C:\Program Files (x86)\Test-(Delete) Me Remove Folder List Files In ProgramFiles Folder
  10. I always find it easier to enclose a string with double quotes using the VBS Chr(34) then trying to count how many quotes are needed. A Way without Chr(34) strCommand = "Setup.exe /UL1033 /V""SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244""" Produces
  11. Cmd line it not wrapped in quotes start/wait Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" VBS requires quotes around the string or the string would be read like a varible that empty "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34) Interpid this way by Cscript.exe or Wscript.exe His Code Setup.exe /UL1033 /V My Code Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" MsgBox "Line 1 " & Some & Text & vbCrLf & "Line 2 Some Text",4128,"Test" will produce His origianl script was failing because he did not have it quoted correct
  12. In order to try and help people (actually coming here and asking for help) we often need to ask questions. You can easily spot them because they have a small "hook" sign "?" at the end. You were asked THREE of them: Which OS? Which Filesystem? what is the output of "SET ProgramFiles"? Right now we have a (vague) answer to only the first one, i.e. now we know that you are running Windows 7 (and probably the 64 bit version of it), and such a system WILL have issues with permissions IF the target is on a NTFS filesystem (question #2) AND it is run NOT with Administrator permission. Them someone may suggest you to try something, like: It would be nice if you could actually try the suggestion and report what happens. jaclaz Now any body with half a brain wouldm of seen this, "%ProgramFiles% and that on Vista and up and if the UAC has not been disable it requires Admin rights to delete any folder or contents.
  13. It seems to me like being NOT the same: in the batch: in the VBS: jaclaz You are wrong This is how it interpids the line at runtime on the second line of the Example script Setup.exe /UL1033 /V "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" The quotes are remove when it being process by the script, when it see a double "" it only read one. Chr(34) = " so it knows the serial number has quotes around it. strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34) When the script process the line it checks to make sure there none of " these are missing In his original script he was trying to double quote EX "Sting In Quotes" so the script will read it like Sting In Quotes where as he needs it to be read as "Sting In Quotes" Clive can you see what wrong here 244'" 244"
  14. I say it a permission issue, if you are using Vista and up. Try to right click the script and select Run As Admin.
  15. You have only one of the below at the end before the quote mark ,could that becausing the problem If you need a area double quoted use Chr(34) = " Test VBS I used to test the strrCommand 'strCommand = " Setup.exe /UL1033 /V"SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244'" strCommand = "Setup.exe /UL1033 /V" & Chr(34) & "SERIALNUMBER=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx COUNTRY=244" & Chr(34) WScript.Echo strcommand
  16. Here is Cmd Promt Script that gives 3 choice Demo_Menu.cmd @Echo OffCLSCOLOR 9FMODE 62,9TITLE Demo Menu::This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.::This is only posted as example code and meant only to used as such.:MainCLSEcho.Echo This Is To Turn On Or Turn Off The Hiberfil.sysEcho.Echo Type 1 For This ChoiceEcho Type 2 For This ChoiceEcho Type Quit To Close WindowEcho.SET Choice=SET /P Choice=Type Choice Then Press Enter:IF /I '%Choice%'=='1' GOTO Item1IF /I '%Choice%'=='2' GOTO Item2IF /I '%Choice%'=='quit' GOTO TheEndECHO "%Choice%" is not valid. Please try again.SET /P = Press Enter To ContinueGOTO MAIN:Item1CLSEcho.Echo You Selected Choice 1ping -n 3 127.0.0.1>nulGoto TheEnd:Item2CLSEcho.Echo You Selected Choice 2ping -n 3 127.0.0.1>nulGoto TheEnd:TheEndExit
  17. You could make one big script and use the delete example at the end of the script.
  18. You can not delete the file without creating Scripting.FileSystemObject, Save As Demo_Delete.vbs '-> Object For Files Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Msgbox With Path And Script Name WScript.Echo WScript.ScriptFullName '-> Delete The File Fso.DeleteFile(WScript.ScriptFullName),True
  19. You do not need any 3rd party application to run a vbs script without showing any Cmd Window. Show Window Option Explicit Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("%comspec% /K assoc.java=java.Document "), 1, True objShell.Run("%comspec% /K ftype java.Document =""C:\Program Files (x86)\Ready to Program\Ready.exe"" ""%1"""), 1, True Hide Window Option Explicit Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("%comspec% /K assoc.java=java.Document "), 0, True objShell.Run("%comspec% /K ftype java.Document =""C:\Program Files (x86)\Ready to Program\Ready.exe"" ""%1"""), 0, True Another Example Hidden Window that produces a text file with no Window Showing CreateObject("Wscript.Shell").Run(_ "%Comspec% /C @Echo Off && CLS && Echo Test Line 1 > Test.txt && " & _ "Ping -n 2 127.0.0.1>nul && Echo Test Line 2 >> Test.txt"),0,True
  20. Here try this script it should sort ot KB Net and misc exe or msi Save As Install_Demo_V2.vbs '-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.'-> Objects For RuntimeDim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Sys :Set Sys = Act.Environment("System")Dim Txt :Txt = Act.SpecialFolders("Desktop") & "\Install_Log.txt"'-> Varibles For RuntimeDim Ln, Obj, S3, Ts, VarLn = "--------------------------------------"S3 = Space(3)'-> Create Text File On User DesktopSet Ts = Fso.CreateTextFile(Txt)Ts.WriteLine vbTab & "Install Application Log"Ts.WriteLine LnTs.WriteLine S3 & "Script Run Time : " & TimeTs.WriteLine S3 & "Script Run Date : " & DateTs.WriteLine S3 & "Cpu Architecture : " & Sys("PROCESSOR_ARCHITECTURE")Ts.WriteLine Ln'-> Path With The Script In Folder = Fso.GetFolder(".").Files'-> Path To The Folder To Process = Fso.GetFolder("PATH_TO_FOLDER_TO_PROCESS").FilesFor Each Obj In Fso.GetFolder(".").Files'-> Filter Out EXE In The FolderVar = Right(LCase(Obj),3)If Var = "exe" Thencall Install_Exe(Obj.Name,Obj.Path)End IfIf Var = "msi" Thencall Install_Exe(Obj.Name,Obj.Path)End IfNext'-> Sort The ExeFunction Install_Exe(N,P)If InStr(1,N,"kb",1) ThenTs.WriteLine S3 & "Install Update : " & N & vbCrLf & _S3 & "Update Location : " & P & vbCrLf & _" Install Switches Places Holder"'-> Code Here For Kb EXEElseIf InStr(1,N,"net",1) ThenTs.WriteLine S3 & "Install Update : " & N & vbCrLf & _S3 & "Net Fw Location : " & P & vbCrLf & _" Install Switches Places Holder"'-> Code Here For Net EXEElse'-> Code Here For Misc EXETs.WriteLine S3 & "Application Name : " & N & vbCrLf & _S3 & "Application Path : " & P & vbCrLf & _" Install Switches Places Holder"End If' Ts.WriteLine Lncall Architecture(N,P)End Function'-> Sort The MsiFunction Install_Msi(N,P)If InStr(1,N,"kb",1) ThenTs.WriteLine S3 & "Install Update : " & N & vbCrLf & _S3 & "Update Location : " & P & vbCrLf & _" Install Switches Places Holder"'-> Code Here For Kb MSIElseIf InStr(1,N,"net",1) ThenTs.WriteLine S3 & "Install Update : " & N & vbCrLf & _S3 & "Net Fw Location : " & P & vbCrLf & _" Install Switches Places Holder"'-> Code Here For Net MSIElse'-> Code Here For Misc MSITs.WriteLine S3 & "Application Name : " & N & vbCrLf & _S3 & "Application Path : " & P & vbCrLf & _" Install Switches Places Holder"End Ifcall Architecture(N,P)End Function'-> OS ArchitectureFunction Architecture(N,P)' Ts.WriteLine LnSelect Case LCase(Sys("PROCESSOR_ARCHITECTURE"))Case "x86"'-> Code Here 64 BitTs.WriteLine Space(3) & "Processing 32 Bit Section"Case "amd64"'-> Code Here 64 BitTs.WriteLine Space(3) & "Processing 64 Bit Section"End SelectTs.WriteLine LnEnd Function'-> End Of Text FileTs.Close'-> Open Text FileAct.Run(Txt),1,True'-> Ask To Keep Or Delete FileIf MsgBox(_"Would you like to keep this file? Yes to Keep, No to Delete" & vbCrLf & _Txt,4132,"Keep Or Delete File") = 7 Then Fso.DeleteFile(Txt), True
  21. Are all the EXE in the same folder and you want to separate KB from Net EXE. to install with different intall switches?
  22. Here this will list all the EXE in the folder that you place this script in. It will produce a text file of what exe where process. Try this out, then if it does what you want then we can add the registry stuff later. Save As Install_Demo.vbs '-> Objects For Runtime Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Sys :Set Sys = Act.Environment("System") Dim Txt :Txt = Act.SpecialFolders("Desktop") & "\Install_Log.txt" '-> Varibles For Runtime Dim Ln, Obj, Ts Ln = "--------------------------------------" '-> Create Text File On User Desktop Set Ts = Fso.CreateTextFile(Txt) Ts.WriteLine vbTab & "Install Application Log" Ts.WriteLine Ln Ts.WriteLine Space(3) & "Script Run Time : " & Time Ts.WriteLine Space(3) & "Script Run Date : " & Date Ts.WriteLine Space(3) & "Cpu Architecture : " & Sys("PROCESSOR_ARCHITECTURE") Ts.WriteLine Ln '-> Path With The Script In Folder = Fso.GetFolder(".").Files '-> Path To The Folder To Process = Fso.GetFolder("PATH_TO_FOLDER_TO_PROCESS").Files For Each Obj In Fso.GetFolder(".").Files '-> Filter Out EXE In The Folder If Right(LCase(Obj),3) = "exe" Then Ts.WriteLine Space(3) & "Installation Of : " & Obj.Name Ts.WriteLine Space(3) & "Application Path : " & Fso.GetFolder(".").Path Select Case LCase(Sys("PROCESSOR_ARCHITECTURE")) Case "x86" '-> Code Here 64 Bit Ts.WriteLine Space(3) & "Processing 32 Bit Section" Case "amd64" '-> Code Here 64 Bit Ts.WriteLine Space(3) & "Processing 64 Bit Section" End Select Ts.WriteLine Ln End If Next ' WScript.Echo Ln Ts.Close '-> Open Text File Act.Run(Txt),1,True '-> Ask To Keep Or Delete File If MsgBox(_ "Would you like to keep this file? Yes to Keep, No to Delete" & vbCrLf & _ Txt,4132,"Keep Or Delete File") = 7 Then Fso.DeleteFile(Txt), True
  23. I modified your script so it adds text every 2 line, I also change the filter for testing Change From Change To VBS Script Dim C1, FSO, txs, fld, fil, content Set FSO = CreateObject("Scripting.FileSystemObject") Set fld = FSO.GetFolder("C:\test\") For Each fil In fld.Files If Right(LCase(fil),3) = "txt" Then Set txs = fil.OpenAsTextStream(1) ' 1 = for reading '-> Loop Threw The Text File And Add New Contents Do until txs.AtEndOfStream = True C1 = C1 + 1 If C1 Mod 2 Then content = content & txs.ReadLine & vbCrLf Else content = content & "MyDisclaimer:" & vbCrLf & txs.ReadLine End If Loop txs.Close '-> Rebuild The Text File With New Contents Set txs = fil.OpenAsTextStream(2) ' 2 = for writing txs.Write content txs.Close End If Next Example Pat.txt Before Script Example Pat.txt After Script
  24. I made Vb.Net app that Expands abd Compresses files using MakeCab, just drag and drop the file on to the app.. You could also put this into the SendTo Folder to have it work from there. MakeCabAndExpand
  25. Here is a vbs script that loops 12 times at 5 second intervals and if Notepad is open will closed it. I have scripted this to run using Cscript.exe Save As TaskKilllProcess.vbs '-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.Dim C1, Obj,Task,WmiSet Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")'-> Make Sure It Runs CscriptIf InStr(1,WScript.FullName,"cscript",1) ThenTaskKill()Else'-> Error Wrong Script EngineMsgBox _"This script was ment to run by this Scripting Engine Cscript.exe" & vbCrLf & _"Right Click this script and select either the Cscript or Cmd Promt", _4128,"Error Wrong Scripting Engine"End If'-> Wait For Task Kill ProcessFunction TaskKill()C1 = C1 + 1If Len(C1) = 1 Then C1 = "0" & C1Do Until C1 = 12'-> Name Of Process To Kill EG Notepad.exeFor Each Obj in Wmi.ExecQuery( _"Select * from Win32_Process Where Name = 'Notepad.exe'")Obj.Terminate()WScript.Echo " Stopping : " & Obj.Name & vbCrLfWScript.Sleep 500NextWScript.Echo " " & C1 & vbTab & "Waiting For Notepad" & vbCrLfWScript.Sleep 5000TaskKill()LoopEnd Function'-> End Of Script MessageWScript.Echo " " & C1 & vbTab & "Exiting Script"WScript.Sleep 1000
×
×
  • Create New...