Jump to content

gunsmokingman

Super Moderator
  • Posts

    2,296
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Canada

Everything posted by gunsmokingman

  1. This will not do all you want, what it does is remove the line with numbers also this will also remove the blank lines from the file. It Produces a Test_ScriptingSamples2.txt with the contents added. The script uses vbs regex to search for the line numbers, I don't use vbs regex very much so don't know how to use it to full capacity. VBS Regex Save As Demo_Regex.vbs '-> Object For Run Time Dim Act :Set Act = CreateObject("WScript.Shell") Dim Fao :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Rex :Set Rex = new regexp '-> Varibles Used At Run Time Dim TsR, TsW, Tx, Vr '-> Check To Make Sure File Exists If Fso.FileExists("ScriptingSamples2.txt") Then '-> Read All Contents Into One Varible Set Ts = Fso.OpenTextFile("ScriptingSamples2.txt") Vr = Ts.ReadAll Ts.Close '-> Create Text File To Write New Contents Set Ts = Fso.CreateTextFile("Test_ScriptingSamples2.txt") '-> Loop Threw The Varible For Each Tx In Split(Vr, vbCrLf) '-> Removes Blank Lines From New File If Not Tx = "" Then '-> Text Pattern Looks For 1, 2,Up To 99 Rex.Pattern ="(\d{1,2})" '-> Not A Match Add It To New File If Not Rex.Test(Tx) Then Ts.WriteLine Tx End If End If Next Ts.Close '-> Open Up The Contents Of The New File Act.Run("Test_ScriptingSamples2.txt") Else MsgBox "Error :Missing This File : ScriptingSamples2.txt", _ 4128,"Error No File Found" End If Rename Demo_Regex.vbs,txt to Demo_Regex.vbs to make active Demo_Regex.vbs.txt
  2. Could you not add something like this to your script, it ask do you want it case sensitive or not case sensitive? This would save having 2 script posted. If MsgBox( _ "Would you like to make the script be Case senistive?" & vbCrLf & _ "Examble Case Insenistive A1b, a1B, A1B are not dublicates" & vbCrLf & _ "and only one entry would be applied" & vbCrLf & _ "Examble Case Senistive A1b, a1B, A1B are dublicates would" & vbCrLf & _ "be added as separate entries" & vbCrLf & _ "Yes to make RemoveLines.vbs case Insenistive" & vbCrLf & _ "No to make RemoveLines.vbs case senistive",4132,"Yes No senistive") = 6 Then '-> Case Insensitive Dic.CompareMode = 1 Else '-> Case Sensitive Dic.CompareMode = 0 End if
  3. I did get it to work with this line gc "C:\Users\Gunsmokingman\Desktop\Test1.Txt" | select -unique | out-file "C:\Users\Gunsmokingman\Desktop\New_Test1.Txt" Output File Contents For One Line it works ok, but what changes would be needed to make it case insensitive.
  4. I really could not get the so called one line solution to work correctly The only output I could was from my last try with Power Shell Contents Of Test1.txt PowerShell Output To New_Test1.txt
  5. Here is a script I wrote that will remove duplicate lines and blank lines from INI INF TXT file types. You can use this script 2 ways 1:\ Drag and Drop the file onto the script 2:\ Cmd Line This will then produce a file called New_FileName.Extension Test File Contents Results Of Script Save As RemoveLines.vbs Dim Dic :Set Dic = CreateObject("Scripting.Dictionary") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Drag One File If WScript.Arguments.Count = 1 Then '-> Process INF, INI,TXT Select Case LCase(Right(WScript.Arguments.Item(0),3)) Case "inf","ini","txt" TextChange(WScript.Arguments.Item(0)) Case Else '-> Not Correct File Type MsgBox "This file is not a valid file type : " & _ Right(WScript.Arguments.Item(0),3) & vbCrLf & _ "Drag And Drop These Types INF INI TXT",4128,_ "Error Wrong File Type" WScript.Quit End Select '-> No File Drag ElseIf WScript.Arguments.Count = 0 Then ErrorMsg("Error File Total : " & WScript.Arguments.Count) '-> To Many Files Drag ElseIf WScript.Arguments.Count >= 2 Then ErrorMsg("Error File Total : " & WScript.Arguments.Count) End If '-> Function To Handle To Many Or Zero Files Function ErrorMsg(N) MsgBox _ "There must be only 1 Text File Type Drag And Drop" & vbCrLf & _ "onto this script. " & N,4128, N WScript.Quit End Function '-> Remove Duplicate Lines Function TextChange(File) Dim Ts, Tx Set File = Fso.GetFile(File) Set Ts = Fso.OpenTextFile(File.Path) '-> 1 = Case Insensitive , 0 = Case Sensitive Dic.CompareMode = 1 Do Until Ts.AtEndOfStream Tx = Ts.ReadLine If Not Dic.Exists(Tx) Then Dic.Add Tx, Tx Loop Ts.Close Set Ts = Fso.CreateTextFile( _ Replace(File.Path,File.Name, "New_" & File.Name)) For Each Tx In Dic.Keys If Not Tx = "" Then Ts.WriteLine Tx Next Ts.Close End Function Sorry for the double attach file I am on Windows 8 and I can not remove one from the post, the site not quite right on Win 8
  6. Could you post the part of the script that you want to make case insensitive
  7. For the record I tested the CMD script on Windows 8 Developers Preview and Windows 7 with the same results.
  8. Since I am not CMD Script expert Example 1 @Echo Off CLS echo mytest0=0>mytest.txt echo mytest1=1>>mytest.txt echo mytest2=2>>mytest.txt echo mytest3=3>>mytest.txt echo mytest4=4>>mytest.txt echo mytest5=5>>mytest.txt echo mytest6=6>>mytest.txt echo mytest7=7>>mytest.txt echo mytest8=8>>mytest.txt echo mytest9=9>>mytest.txt Would produce this text output Add this ^ before the numbers @Echo Off CLS echo mytest0=^0>mytest.txt echo mytest1=^1>>mytest.txt echo mytest2=^2>>mytest.txt echo mytest3=^3>>mytest.txt echo mytest4=^4>>mytest.txt echo mytest5=^5>>mytest.txt echo mytest6=^6>>mytest.txt echo mytest7=^7>>mytest.txt echo mytest8=^8>>mytest.txt echo mytest9=^9>>mytest.txt Produces this text output
  9. Here try this VBS script, just place it in the folder that you want the files to be rename. RenameToFourCharacters.vbs '-> Object For Runtime Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles For Runtime Dim Obj, V1, V2 '-> Loop Threw The Parent Folder File For Each Obj In Fso.GetFolder(".").Files '-> Separate The Script From Other Files If Not LCase(Right(Obj.Name,3)) = "vbs" Then '-> Get The First Four Characters For The Shorten Name V1 = Left(Obj.Name,4) '-> Get The Last Four Characters For The Extension V2 = Right(Obj.Name,4) '-> Move The Old Name To The New Names Fso.MoveFile Obj.Path, Replace(Obj.Path,Obj.Name, V1 & V2) End If Next Rename this RenameToFourCharacters.vbs.txt to RenameToFourCharacters.vbs to make active This does the same as above, but it produces a cmd promt window and displays old new name changes. RenameFourChar.vbs '-> Object For Runtime Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") '-> Varibles For Runtime Dim Obj, V1, Arw: Arw = Chr(187) & Chr(160) '-> Make Sure It Cscript.exe If InStr(1,WScript.FullName,"cscript",1) Then Rename() Else MsgBox vbTab & "Error " & Arw & "Wrong Scripting Engine" & vbCrLf & _ Arw & "This script was ment to be run using Cscript.exe, and not" & vbCrLf & _ "this scripting Wscript.exe. Right Click this script and select" & vbCrLf & _ "either Cmd Promt or Cscript.exe from the menu",4128,"Error" End If Function Rename() '-> Loop Threw The Parent Folder File For Each Obj In Fso.GetFolder(".").Files '-> Separate The Script From Other Files If Not LCase(Right(Obj.Name,3)) = "vbs" Then '-> New File Name V1 = Left(Obj.Name,4) & Right(Obj.Name,4) '-> Move The Old Name To The New Names If Not Exists If Not Fso.FileExists(Replace(Obj.Path,Obj.Name, V1)) Then WScript.StdOut.WriteLine "Old Name " & Arw & Obj.Name WScript.StdOut.WriteLine "New Name " & Arw & V1 & vbCrLf WScript.Sleep 55 Fso.MoveFile Obj.Path, Replace(Obj.Path,Obj.Name, V1) Else WScript.StdOut.WriteLine "UnChange " & Arw & Obj.Name & vbCrLf End If End If Next '-> Wait For The Enter Key To Be Pressed WScript.StdOut.WriteLine "Press Enter To Close Window" Do While WScript.StdIn.AtEndOfLine WScript.Quit() Loop End Function
  10. When I ran this as a test a selected cancel it return 2, give it a try on your computer after you change the app path and switches. Dim Act :Set Act = CreateObject("Wscript.Shell") Dim i,App '-> Chr(34) = " '-> App = Chr(34) & "Path\To\App" & Chr(34) & " /Switches" App = Chr(34) & "E:\App\audioextractor.exe" & Chr(34) & " /S" i = Act.Run(App,1,True) MsgBox "Exit Code is : " & (i),4128, "Install Exit Code"
  11. Here is a way of doing what the poster wants using VBS script. Dim Pets :Pets = Array("Cats","Dogs","Horses") Dim a,c,i,z '-> Loop Threw Pets Array For Each a In Pets c = c + 1 call SortArray(a, c) Next '-> Function To Display Pets Array And Names Function SortArray(Item, N) Select Case N Case 1 :i = Array("FiFi", "FruFru", "Fluffy") Case 2 :i = Array("Lassie", "MrMuggles", "RinTinTin") Case 3 :i = Array("MrEd", "Trigger", "Silver") End Select For Each z In i WScript.Echo Item & vbTab & z Next End Function Produces this output Cats FiFi Cats FruFru Cats Fluffy Dogs Lassie Dogs MrMuggles Dogs RinTinTin Horses MrEd Horses Trigger Horses Silver
  12. If the person wanted to use VBS Script Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Folder :Folder = "C:\Temp" If Not Fso.FolderExists(Folder) Then Fso.CreateFolder(Folder) Else Fso.DeleteFolder(Folder),True Fso.CreateFolder(Folder) End If
  13. Here try this script it a Recursive script that looks for the ini Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Col, Obj '-> Script In Same Folder You Want To Recursive Recursive(Fso.GetFolder(".")) '-> Path To Recursive Folder UnComment To Make Active ' Recursive(Fso.GetFolder("PLACE_PATH_TO_FOLDER")) Function Recursive(Folder) For Each Col In Folder.Files If LCase(Right(Col.Name,3)) = "ini" Then WScript.Echo Col.Path End If Next For Each Obj In Folder.SubFolders Recursive(Obj) Next End Function Rename Recursive.vbs.txt to Recursive.vbs to make active Recursive.vbs.txt
  14. I would recommend leaving a way for the script to quit, you could increase the time between cycles. '-> Waits 60 Seconds If C1 = 60 Then 5 min between cycles '-> Waits 300 Seconds If C1 = 300 Then 10 min between cycles '-> Waits 600 Seconds If C1 = 600 Then
  15. You wont need Set WshNetwork = CreateObject("WScript.Network") because I have the Network object as Set objNetwork = WScript.CreateObject("WScript.Network") so all you need to add '-> Code Here To Add Printer PrinterPath = "\\server01\2F18P" objNetwork .SetDefaultPrinter "\\server01\2F18P"
  16. Read this $OEM$ Distribution Folders on how to create a folder in your source that will get copy automatically during the install.
  17. Here is a VBS Script 1:\ Loops Until Chk = True 2:\ Every 60 Seconds Msgbox ask quit or wait Set objNetwork = WScript.CreateObject("WScript.Network") Set colPrinters = objNetwork.EnumPrinterConnections Dim C1, C2, Chk, Printer '-> Place The Printer You Want To Check For Printer = "hp officejet 4100 series" '-> Loops Until True Do Until Chk = True C1 = C1 + 1 For i = 0 to colPrinters.Count -1 Step 2 If colPrinters.Item(i + 1) = Printer Then '-> Code Here To Add Printer Wscript.Echo "Adding Printer : " & colPrinters.Item(i + 1) Chk = True End If Next WScript.Sleep 1000 '-> Waits 60 Seconds If C1 = 60 Then C2 = C2 + 1 '-> Msgbox Ask To Quit Or Wait If MsgBox(_ " Script Has Been Active For : " & C2 & " Minutes." & vbCrLf & vbCrLf & _ "Would you like to quit the script or wait for" & vbCrLf & _ "the printer to be added?" & vbCrLf & vbCrLf & _ "No to quit this script and not add the printer," & vbCrLf & _ "Yes to wait for the printer to be added?",4132,"Quit Or Contimue") = 7 Then WScript.Quit Else '-> Yes Selected Reset Counter To Zero C1 = 0 End If End If Loop Rename ChkWaitAddPrinter.vbs.txt to ChkWaitAddPrinter.vbs to make active script ChkWaitAddPrinter.vbs.txt
  18. Perhaps this Managing Network Printers Link Here is a code sample from the link with a check for your printer, I tested only for run time errors and there was none on my computer. Example with check Set objNetwork = WScript.CreateObject("WScript.Network") Set colPrinters = objNetwork.EnumPrinterConnections For i = 0 to colPrinters.Count -1 Step 2 If colPrinters.Item(i) = "\\server01\2F18P" Then Wscript.Echo colPrinters.Item(i) & vbTab & colPrinters.Item (i + 1) End if Next
  19. Could you provide more infomation about what you want. Here is a Vbs Script that uses AppActivate and SendKeys Method 1:\ Open Notepad 2:\ Add Some Text 3:\ Save And Closes the new Text flle AppActivate And Sending Keystrokes to a Program Save As Demo_SendKey.vbs Dim Act :Set Act = CreateObject("Wscript.Shell") Act.Run("Notepad.exe"),1,False Do Until Success = True Success = Act.AppActivate("Notepad") Wscript.Sleep 1000 Loop Act.SendKeys "This is a test of AppActivate." WScript.Sleep 1000 Act.SendKeys "{ENTER}" Act.SendKeys "T" :WScript.Sleep 500 Act.SendKeys "e" :WScript.Sleep 500 Act.SendKeys "s" :WScript.Sleep 500 Act.SendKeys "t" :WScript.Sleep 500 Act.SendKeys "%F" Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{ENTER}" :WScript.Sleep 500 Act.SendKeys "Demo_Send_Key.txt" Act.SendKeys "{ENTER}",500 Act.SendKeys "%F" :WScript.Sleep 1000 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{DOWN}" :WScript.Sleep 500 Act.SendKeys "{ENTER}" :WScript.Sleep 500 Rename Demo_SendKey.vbs.txt to Demo_SendKey.vbs to make active. Demo_SendKey.vbs.txt
  20. Here is a updated version at with 137 lines of code and can can be edit by something as simple as notepad. <Title>My Demo Message Box</Title> <HTA:APPLICATION ID="MyMessageBox" SCROLL="No" SCROLLFLAT ="No" SingleInstance="Yes" ShowInTaskbar="Yes" SysMenu="Yes" MaximizeButton="No" MinimizeButton="No" Border="Thin" BORDERSTYLE ="complex" INNERBORDER ="No" Caption="Yes" WindowState="Normal" APPLICATIONNAME="MainApp" Icon="%SystemRoot%\explorer.exe"> <STYLE type="text/css"> BODY{ Font-Size:8.25pt; Font-Weight:Bold; Font-Family:helvetica,verdana,arial; Color:#008040; BackGround-Color:Transparent; filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E2E2E2',EndColorStr='#6e6e6e); Margin-Top:5; Margin-Bottom:5; Margin-Left:5; Margin-Right:5; Padding-Top:3; Padding-Bottom:3; Padding-Left:5; Padding-Right:5; Text-Align:Left; Vertical-Align:Top; } TD.Type1{ Margin-Left:21; Padding-Left:15; } BUTTON{ Height:18pt; width:61pt; Cursor:Hand; Font:8.05pt; Font-weight:bold; Font-family:helvetica,verdana,arial; Color:#404040; Text-Align:Center; Vertical-Align:Middle; filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E5E5E5',EndColorStr='#7D7D7D'); Margin:1; Padding:2; Border-Left: 1px Transparent; Border-Right: 2px Transparent; Border-Top: 1px Transparent; Border-Bottom: 2px Transparent; } </STYLE> <script Language='VBSCRIPT'> Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%Temp%") & "\MyReturn.cmd" Dim Wth, Hht :Wth = int(425) :Hht = int(175) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2)) Dim F1 :F1 = "<FONT STYLE='Font:8.25pt;Color:#002060;Font-Weight:Bold;'>" Dim idTimer, Y_DoIt Dim C1, D1 :C1 = 30 :D1 = 1 Function Window_OnLoad() Counter() txt1.innerHTML = F1 & "Ask Your Question About What You Want Done</FONT>" txt2.innerHTML = F1 & "Here Is Some More Text Space For You If Needed</FONT>" End Function Function Counter() Do D1 = D1 -1 :C1 = C1 -1 :document.focus() If Len(C1) = 1 Then C1 = "0" & C1 If Len(C1) = 2 Then C1 = C1 txt3.innerHTML = F1 & "Remaining Time Before Auto Select Yes " & C1 & "</FONT>" Loop Until D1 = 0 D1 = 1 If C1 = 0 Then Y_DoIt = True HtaExit() Exit Function End if idTimer = window.setTimeout("Counter", 1000, "VBScript") If Y_DoIt = True Then Yes_Work() End Function Function No_Action() Bttn_Y.disabled = True txt3.innerHTML = Replace(F1,"002060","AD0101") & "No Was Selected Cancel All Operation</FONT>" MkCmd("No") window.clearTimeout(idTimer) idTimer = window.setTimeout("MyTimer2", 5000, "VBScript") Exit Function End Function Function Yes_Action() Y_DoIt = True End Function Function Yes_Work() Bttn_N.disabled = True txt3.innerHTML = Replace(F1,"002060","006020") & "Processing Yes Selection</FONT>" MkCmd("Yes") window.clearTimeout(idTimer) idTimer = window.setTimeout("MyTimer1", 3000, "VBScript") End Function Function HtaExit() window.clearTimeout(idTimer) If Y_DoIt = True Then Yes_Work() End Function Function MyTimer1() txt3.innerHTML = "" window.close() window.clearTimeout(idTimer) End Function Function MyTimer2() txt3.innerHTML = "" window.close() window.clearTimeout(idTimer) End Function Function MkCmd(T) Dim Ts : Set Ts = Fso.CreateTextFile(Cmd) Ts.WriteLine "@Echo && CLS && MODE 55,5 && COLOR F9" Ts.WriteLine "Set Reply=" & T Ts.Close End Function </SCRIPT> <BODY Scroll='No'> <Table><TD Class='Type1'><Span ID='txt1'></Span></TD></Table> <Table><TD Class='Type1'><Span ID='txt2'></Span></TD></Table> <Table><TD Class='Type1'><Span ID='txt3'></Span></TD></Table> <Table Style='Margin-Top:7pt;' Align='Center'> <TD><BUTTON ID='Bttn_N' OnClick='No_Action()'>No</BUTTON></TD> <TD><BUTTON ID='Bttn_Y' OnClick='Yes_Action()'>Yes</BUTTON></TD> </Table> </BODY> YesNo_Updated.zip I also wrote this 39 lines of code with comments in Vb.net 2008 Imports System Imports System.IO Public Class Form1 Dim Yes Dim C1 = 30 '-> Stsrt Timer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() End Sub '-> Yes Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Yes = 1 End Sub '-> No Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Yes = 2 End Sub '-> Start The Timer Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick CountDown() End Sub '-> Count Down Private Sub CountDown() If C1 < 10 Then C1 = "0" & C1 If Yes = 1 Then MakeCmd("Yes") If Yes = 2 Then MakeCmd("No") If C1 = 0 Then MakeCmd("Timed-Out") Counter.Text = "Time Left : " & C1 C1 = C1 - 1 End Sub '-> Make Reply Cmd With Yes No Time Out Private Sub MakeCmd(ByVal T As String) Dim Cmd = My.Computer.FileSystem.SpecialDirectories.Temp & "\MyReturn.cmd" Dim sw As StreamWriter = New StreamWriter(Cmd) sw.Write("Set Reply=" & T) sw.Close() Me.Close() End Sub End Class VB.Net 2006 Source Code YesNo_Demo.zip Cmd Promt I Used To Read The Responce @Echo Off CLS Mode 79,11 Color F9 Title Test Return Set Cmd1="%Temp%\MyReturn.cmd" If Exist %Cmd1% GoTO Work1 If Not Exist %Cmd1% GoTO Ops1 :Work1 call %Cmd1% CLS IF /I '%Reply%'=='Yes' GOTO Y1 IF /I '%Reply%'=='No' GOTO N1 IF /I '%Reply%'=='Timed-Out' GOTO T1 Goto TheEnd :Ops1 Color F5 CLS Echo. Echo Missing %Cmd1% Echo Contact The System Admin For More Information! pause Exit :Y1 CLS Echo. Echo User Selected : %Reply% Echo. Pause GoTo TheEnd :N1 CLS Echo. Echo User Selected : %Reply% Echo. Pause GoTo TheEnd :T1 CLS CLS Echo. Echo Auto Action : %Reply% Echo. Pause GoTo TheEnd :TheEnd Del %Cmd1% Exit
  21. Change This Dim Cmd :Cmd = Act.ExpandEnvironmentStrings("%userprofile%\desktop") & "\BannerResult.cmd" To this to get the output in the Current Directory Dim Cmd :Cmd = Act.CurrentDirectory & "\BannerResult.cmd"
  22. Here is a better VBS script that uses Wmi to Defrag All Local Hard Drives without 200 GB filter Save As Wmi_DefragAll.vbs How To Use 1:\ Open Cmd Promt As Admin 2:\ Type in CD Path_To_VBS_Script 3:\ Type in Cscript Wmi_DefragAll.vbs Const GB = 1073741824 Dim Wmi :Set Wmi = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\.\root\cimv2") Dim Dfg, Dsk, errResult, Free, Size, Used, vB :vB = vbCrLf For Each Dsk In Wmi.ExecQuery("Select * from Win32_LogicalDisk") If Dsk.DriveType = 3 Then Free = FormatNumber(Dsk.FreeSpace/GB,2) Size = FormatNumber(Dsk.Size/GB,2) Used = FormatNumber(Size - Free) For Each Dfg in Wmi.ExecQuery("Select * From Win32_Volume" & _ " Where Name = '" & Dsk.DeviceID & "\\'") WScript.StdOut.WriteLine _ "Defraging : " & Dsk.DeviceID & vB & _ "Disk Size : " & Size & " GB" & vB & _ "Disk Free : " & Free & " GB" & vB & _ "Disk Used : " & Used & " GB" & vB & _ "Volume Name : " & Dsk.VolumeName errResult = Dfg.Defrag() WScript.StdOut.WriteLine "Defrag Finished" WScript.StdOut.WriteBlankLines 2 Next End If Next WScript.StdOut.WriteLine "Defrag All Local Drives Completed" Rename Wmi_DefragAll.vbs.txt to Wmi_DefragAll.vbs to make active Wmi_DefragAll.vbs.txt
  23. I know he did not want a VBS script, but I thought I would post a VBS script that list Drives Under And Over 200 GB. Save As DrvFreeSpace.vbs Const GB = 1073741824 Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim A1, A2, Free, Drv, Obj For Each Obj In Fso.Drives If Obj.IsReady Then Free = FormatNumber(Obj.FreeSpace/GB,2) Drv = Obj.DriveLetter & ":\" If Obj.FreeSpace < 214748364800 Then A1 = A1 & vbCrLf & "Under 200 GB" & vbTab & Drv & vbTab & Free & " GB" Else A2 = A2 & vbCrLf & "Over 200 GB " & vbTab & Drv & vbTab & Free & " GB" End If End If Next MsgBox "Drive Free Space Report" & vbCrLf & A1 & A2,4128,"Drive Report"
  24. Perhaps this is better, you can add as many name tto the querry, and in theroy can run on a remote machine. Demo_RecycleBin.vbs '-> Objects For Runtime Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") Dim Wmi :Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Dim Col :Set Col = Wmi.ExecQuery("Select * From Win32_Directory Where Path =" & _ " '\\$Recycle.Bin\\' Or Path = '\\RECYCLER\\'") If Col.Count < 1 Then MsgBox "Could Not Find Any Path With " & _ "\\$Recycle.Bin\\ Or \\RECYCLER\\" Else '-> Confirm Found At Least One Folder Name Dim Obj,Ts, Txt Txt = Act.SpecialFolders("Desktop") & "\RecyleBinRpt.txt" Set Ts = Fso.CreateTextFile(Txt) For Each Obj in Col Ts.WriteLine Obj.caption Next Ts.Close Act.Run(Chr(34) & Txt & Chr(34)),1,True If MsgBox("Would You Like To Keep This File?" & vbCrLf & _ "Yes To Keep File, No To Delete File" & vbCrLf & _ Txt,4132,"Keep Or Delete") = 7 Then Fso.DeleteFile(Txt) End If End If Rename Demo_RecycleBin.vbs.txt to Demo_RecycleBin.vbs to make active Demo_RecycleBin.vbs.txt You can also use some thing like this, but I dont have much experience using this object. I choose to use Wmi I understand it a little better then using what below. Const RECYCLE_BIN = &Ha& Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.NameSpace(RECYCLE_BIN)
  25. I added a png and a hta to C:\IRecyleMyBin_1 and only png to C:\Users\Gunsmokingman\Desktop\IRecyleMyBin The results was that it did not list those 2 folders in the text file output. As to why it pick up those folders on your computer I do know why.
×
×
  • Create New...