
jslegers
Active Members-
Posts
60 -
Joined
-
Last visited
Everything posted by jslegers
-
Got it Notepad was broken at this side. Sorry guys for this noob question.
-
Hello, I have made the following script : #include <MsgBoxConstants.au3> If @ProcessorArch = "X86" Then MsgBox($MB_OK, "Tutorial", "32 Bit") Run("tc86\calc.exe", "") Else MsgBox($MB_OK, "Tutorial", "64 Bit") Run("tc64\notepad.exe", "") EndIf I can't get in this case notepad run from the subdirectory tc64. I have also tried .\tc64\notepad.exe and ..\tc64\notepad.exe no luck with both. What am I doing wrong ?
-
Is there a autoit version of this VB script ?
jslegers replied to jslegers's topic in AutoIt General Help and Support
Thanks for the tips I will try it. -
Hello, I'm using this script at a customer of mine to cleanup locale user profiles : Const LocalDocumentsFolder = "C:\Documents and Settings\" set objFSO = createobject("Scripting.FileSystemObject") set objFolder = objFSO.GetFolder(localdocumentsfolder) on error resume next for each fldr in objFolder.SubFolders if not isexception(fldr.name) then objFSO.DeleteFolder fldr.path, True end if next Function isException(byval foldername) select case foldername case "All Users" isException = True case "Default User" isException = True case "LocalService" isException = True case "NetworkService" isException = True case "Administrator" isException = True case "Nood" isException = True case Else isException = False End Select End Function Is there an Autoit version for this. Would be nice if the exceptions could be set in a ini file. John
-
Create .nfo file based on a file name with subdirs
jslegers replied to jslegers's topic in AutoIt General Help and Support
Thanks for the replies. I will try it. -
Hello, I have seen this topic : http://www.autoitscript.com/forum/index.php?showtopic=110281&st=0&p=775935&hl=nfo&fromsearch=1&#entry775935 Is it possible to run this script on files in sub directories ? Example structure : [Dir] Movie1 Movie1.mkv [Dir] Movie2 Movie2.mkv [Dir] Movie3 Movie3.mkv Result : [Dir] Movie1 Movie1.mkv Movie1.nfo [Dir] Movie2 Movie2.mkv Movie2.nfo [Dir] Movie3 Movie3.mkv Movie3.nfo The .nfo files need to be filled with an url of IMDB I will copy and paste that. And if there is already an .nfo file it needs to skip the directory before it clears the old .nfo file. John
-
Hello, I want to create a script that can read a csv file and use this data to create users in Active Directory with the tool dsadd. CSV file looks like this : ABeerens;Ans Beerens;Ans;Beerens;Welkom01 ABos;Annemiek Bos;Annemiek;Bos;Welkom01 ABraat;Ans Braat;Ans;Braat;Welkom01 Is it possible to create variables from the different pieces in the file. For example $Var1=ABeerens $Var2=Ans Beerens $Var3=Ans $Var4=Beerens $Var5=Welkom01 dsadd $Var1,Var2 .... Loop And so on. I want to create a loop until the end of the file is reached.
-
Hi, I have used this code : #include <Array.au3> $Numbers = 10 $Range = 80 Local $aRandom[$Numbers+1] = ["Generated numbers"] For $i = 1 To $Numbers $aRandom[$i] = Random(1, $Range, 1) For $j = 1 To $i If $i = $j Then ContinueLoop If $aRandom[$i] = $aRandom[$j] Then $i -= 1 Next $Result1 = $aRandom[$i] & $Result1 Next _ArraySort($aRandom ,0 ,1) ;_ArrayDisplay($aRandom, "Lotto") $Result1 = $aRandom[1]&" "&$aRandom[2]&" "&$aRandom[3]&" "&$aRandom[4]&" "&$aRandom[5] MsgBox ( 4096, "Test", $Result1 ) Is it possible to make $Result1 = $Result1&" "&$aRandom[$i]&" " so that the results get added in one line.
-
Hi, Easier as in smaller like you did. Looks great. Thanks for the input.
-
Hello, I have created a Lotto Generator for fun. #include <Array.au3> #include <GuiConstants.au3> Dim $R[11] Dim $Getal1 ; GUI GuiCreate("Lucky Day Generator", 240, 80, -1, -1) ;GuiCreate("Lucky Day Generator", 240, 120, -1, -1, $WS_BORDER, $WS_EX_TOPMOST) GUICtrlCreateLabel(" ",5 ,20, 240) GUICtrlCreateLabel("Lucky nummers : " ,5, 20) GUISetState() $Genereer = GUICtrlCreateButton("Genereer", 30, 50, 75, 23) $Stoppen = GUICtrlCreateButton("Stoppen", 135, 50, 75, 23) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $Stoppen Then ExitLoop If $msg = $Genereer Then Randomize() GUICtrlCreateLabel(" ",5 ,20, 240) GUICtrlCreateLabel("Lucky nummers : " & $Getal1, 5, 20) EndIf WEnd Func Randomize() $R[1] = Random(1, 80, 1) $R[2] = Random(1, 80, 1) $R[3] = Random(1, 80, 1) $R[4] = Random(1, 80, 1) $R[5] = Random(1, 80, 1) $R[6] = Random(1, 80, 1) $R[7] = Random(1, 80, 1) $R[8] = Random(1, 80, 1) $R[9] = Random(1, 80, 1) $R[10] = Random(1, 80, 1) If $R[1] = $R[2] Or $R[1] = $R[3] Or $R[1] = $R[4] Or $R[1] = $R[5] Or $R[1] = $R[6] Or $R[1] = $R[7] Or $R[1] = $R[8] Or $R[1] = $R[9] Or $R[1] = $R[10] Then Randomize () If $R[2] = $R[3] Or $R[2] = $R[4] Or $R[2] = $R[5] Or $R[2] = $R[6] Or $R[2] = $R[7] Or $R[2] = $R[8] Or $R[2] = $R[9] Or $R[2] = $R[10] Then Randomize () If $R[3] = $R[4] Or $R[3] = $R[5] Or $R[3] = $R[6] Or $R[3] = $R[7] Or $R[3] = $R[8] Or $R[3] = $R[9] Or $R[3] = $R[10] Then Randomize () If $R[4] = $R[5] Or $R[4] = $R[6] Or $R[4] = $R[7] Or $R[4] = $R[8] Or $R[4] = $R[9] Or $R[4] = $R[10] Then Randomize () If $R[5] = $R[6] Or $R[5] = $R[7] Or $R[5] = $R[8] Or $R[5] = $R[9] Or $R[5] = $R[10] Then Randomize () If $R[6] = $R[7] Or $R[6] = $R[8] Or $R[6] = $R[9] Or $R[6] = $R[10] Then Randomize () If $R[7] = $R[8] Or $R[7] = $R[9] Or $R[7] = $R[10] Then Randomize () If $R[8] = $R[9] Or $R[8] = $R[10] Then Randomize () If $R[9] = $R[10] Then Randomize () _ArraySort($R, 0, 1) $Getal1 = $r[1]&" "&$r[2]&" "&$r[3]&" "&$r[4]&" "&$r[5]&" "&$r[6]&" "&$r[7]&" "&$r[8]&" "&$r[9]&" "&$r[10] EndFunc Is this the best way or could it be made easier? The long If statements are for that I get unique numbers and not the same. John
-
Checking on IP address Range
jslegers replied to jslegers's topic in AutoIt General Help and Support
Thanks for the replies it works. -
Hello, I want to make a script that could check on ip address and then perform a installation. Before I begin I want to know if this is possible. I want some thing like : If ip address is in range 10.10.10.1 to 10.10.10.255 than execute program a If ip address is in range 10.10.20.1 to 10.10.20.255 than execute program b Is this possible?
-
I need to use the quotes.
-
Hi, I have the following code : $var1 = String ( '"' & @ScriptDir & "\new_1.log" & '"' ) $var2 = FileReadLine ( $var1, 2 ) MsgBox ( 4096,"Test",$var2 ) It looks like that FileReadLine can't read filenames with a path between quotes. Files are placed for test : c:\Documents and Settings\JSL\My Documents\Autoit Scripts\Log file\var.au3 Is this a limitation of FileReadLine ?
-
Script can't calculate anymore
jslegers replied to jslegers's topic in AutoIt General Help and Support
Thanks that did the trick. -
Hello, This is the third time my script is playing tricks on me. Here's the script. #include <Date.au3> ; Setting autoit options AutoItSetOption ( "TrayMenuMode", 1 ) HotKeySet ( "#{ESC}", "Quit" ) If IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "TrayIcon", 1 ) = 0 Then TraySetState ( 2 ) Else TraySetState ( 1 ) EndIf If IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "Optimize", 1 ) = 0 Then $Opt = 2 Else $Opt = 3 EndIf ; Determing language and setting variables If @OSLang = 0409 Then $StartAn = "Starting analyze of fragmentation at " $Analy = "Analyzing " $Start = "Starting defragmentation of " $Defrag = "Defragmenting " $NoDefrag = "No defragmentation needed for " $Drive = " drive." ElseIf @OSLang = 0413 Then $StartAn = "Start met de analyse van de fragmentatie om " $Analy = "Analiseren van de " $Start = "Starten van defragmenteren " $Defrag = "Defragmenteren van de " $NoDefrag = "Geen defragmentatie nodig van " $Drive = " schijf." EndIf $Varfragini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "FragmentedFiles", 100 ) $Vartimeini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "Timeout", 5 ) ;ConsoleWrite($Vartimeini & @LF) ; Adding x minutes to the current time $sTime = _DateAdd ( 'n', $Vartimeini, _NowCalc()) $sNewTime = _DateTimeFormat ( $sTime, 4 ) ; Setting Tray Icons options. TraySetToolTip ( $StartAn & $sNewTime ) ; Waiting for x minutes. Sleep ( $Vartimeini * 60000 ) $Vardrive = DriveGetDrive( "FIXED" ) If NOT @error Then For $i = 1 to $Vardrive[0] ; Analyzing drive. TrayTip ( "", $Analy & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) $JkDefragCom = "C:\Program Files\Defrag\JkDefragCmd.exe" $JkParam = "-a 1 -l C:\Analyze_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) $Log = FileReadLine ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ,18 ) $Ret = StringRegExp($Log, ": ([0-9]{0,})", 1, 1) ;FileDelete ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ) ConsoleWrite($Ret[0] & @LF) If $Ret[0] > $Varfragini Then ; Starting defragmentation of drive. TrayTip ( "", $Start & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) Sleep ( 3000 ) TrayTip ( "", "", 0 ) TraySetToolTip ( $Defrag & StringUpper ( $Vardrive[$i] ) & $Drive ) $JkParam = "-a " & $Opt & " -d 1 -s 100 -f 1 -l C:\Defrag_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) Else TrayTip ( "Status", $NoDefrag & StringUpper ( $Vardrive[$i] ) & $Drive, 10, 1 ) Sleep ( 3000 ) EndIf Next EndIf ; Function Quit to stop the script. Func Quit() ProcessClose ( "JkDefragCmd.exe" ) Exit EndFunc Here is the ini file : [General] FragmentedFiles=500 Timeout=0 TrayIcon=1 Optimize=1 And here is a piece of the analyze log file : 15:54:34 JkDefrag v3.36 15:54:34 Date: 2008/09/12 15:54:34 Windows version: v5.1 build 2600 Service Pack 3 15:54:34 Commandline argument '-a' accepted, optimizemode = 1 15:54:34 Commandline argument '-l' accepted, logfile = C:\Analyze_C.log 15:54:34 NtfsDisableLastAccessUpdate is active, ignoring LastAccessTime for SpaceHogs. 15:54:34 Processing 'c:' 15:54:34 Opening volume '\\?\Volume{e8f1f9b1-60cc-11dd-b040-806d6172696f}' at mountpoint 'c:' 15:54:34 Input mask: c:\* 15:54:35 Phase 1: Analyze 15:54:35 This is an NTFS disk. 15:54:45 Finished. 15:54:45 - Total disk space: 34356477952 bytes (31.9970 gigabytes), 8387812 clusters 15:54:45 - Bytes per cluster: 4096 bytes 15:54:45 - Number of files: 89795 15:54:45 - Number of directories: 5286 15:54:45 - Total size of analyzed items: 15630741504 bytes (14.5573 gigabytes), 3816099 clusters 15:54:45 - Number of fragmented items: 1827 (1.9215% of all items) My script checks by the ini file if this drive has to be defragmented. As you can see the number of fragmented items = 1827. In the ini file there is a limit of 500. So in the script it says If 1827 > 500 then defrag. But this doesn't work. If the value is below 1000 say 600 than I runs fine. Why does it has problems with numbers bigger than 1000 ? Could this line be faulty $Log = FileReadLine ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ,18 ) $Ret = StringRegExp($Log, ": ([0-9]{0,})", 1, 1)JkDefragCmd.exe
-
Hi, Thanks. The trailing comma was the problem.
-
Hi Brett, The strange thing is it has always worked. I creates the file nicely. Looks like this part : $Log = FileReadLine ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ,18 ) $Ret = StringRegExp ( $Log, ": ([0-9]{0,}),", 1, 1 ) doesn't work anymore.
-
Hi, I have made a script which starts JkDefrag with a few parameters and which tests if files are fragmented. Here is the script : Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Defrag.ico #AutoIt3Wrapper_outfile=Defrag.exe #AutoIt3Wrapper_Res_Description=Defrag script for JKDefrag #AutoIt3Wrapper_Res_Fileversion=1.3.2.0 #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <Date.au3> ; Setting autoit options AutoItSetOption ( "TrayMenuMode", 1 ) HotKeySet ( "#{ESC}", "Quit" ) If IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "TrayIcon", 1 ) = 0 Then TraySetState ( 2 ) Else TraySetState ( 1 ) EndIf If IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "Optimize", 1 ) = 0 Then $Opt = 2 Else $Opt = 3 EndIf ; Determing language and setting variables If @OSLang = 0409 Then $StartAn = "Starting analyze of fragmentation at " $Analy = "Analyzing " $Start = "Starting defragmentation of " $Defrag = "Defragmenting " $NoDefrag = "No defragmentation needed for " $Drive = " drive." ElseIf @OSLang = 0413 Then $StartAn = "Start met de analyse van de fragmentatie om " $Analy = "Analiseren van de " $Start = "Starten van defragmenteren " $Defrag = "Defragmenteren van de " $NoDefrag = "Geen defragmentatie nodig van " $Drive = " schijf." EndIf $Varfragini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "FragmentedFiles", 100 ) $Vartimeini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "Timeout", 5 ) ;ConsoleWrite($Vartimeini & @LF) ; Adding x minutes to the current time $sTime = _DateAdd ( 'n', $Vartimeini, _NowCalc()) $sNewTime = _DateTimeFormat ( $sTime, 4 ) ; Setting Tray Icons options. TraySetToolTip ( $StartAn & $sNewTime ) ; Waiting for x minutes. Sleep ( $Vartimeini * 60000 ) $Vardrive = DriveGetDrive( "FIXED" ) If NOT @error Then For $i = 1 to $Vardrive[0] ; Analyzing drive. TrayTip ( "", $Analy & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) $JkDefragCom = "C:\Program Files\Defrag\JkDefragCmd.exe" $JkParam = "-a 1 -l C:\Analyze_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) $Log = FileReadLine ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ,18 ) $Ret = StringRegExp ( $Log, ": ([0-9]{0,}),", 1, 1 ) ;FileDelete ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ) ConsoleWrite ( $Ret[0] & @LF ) If $Ret[0] > $Varfragini Then ; Starting defragmentation of drive. TrayTip ( "", $Start & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) Sleep ( 3000 ) TrayTip ( "", "", 0 ) TraySetToolTip ( $Defrag & StringUpper ( $Vardrive[$i] ) & $Drive ) $JkParam = "-a " & $Opt & " -d 1 -s 100 -f 1 -l C:\Defrag_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) Else TrayTip ( "Status", $NoDefrag & StringUpper ( $Vardrive[$i] ) & $Drive, 10, 1 ) Sleep ( 3000 ) EndIf Next EndIf ; Function Quit to stop the script. Func Quit() ProcessClose ( "JkDefragCmd.exe" ) Exit EndFunc This is an example of the log file which is being created : 13:36:47 JkDefrag v3.36 13:36:47 Date: 2008/09/02 13:36:47 Windows version: v5.1 build 2600 Service Pack 3 13:36:47 Commandline argument '-a' accepted, optimizemode = 1 13:36:47 Commandline argument '-l' accepted, logfile = C:\Analyze_C.log 13:36:47 NtfsDisableLastAccessUpdate is active, ignoring LastAccessTime for SpaceHogs. 13:36:47 Processing 'c:' 13:36:47 Opening volume '\\?\Volume{e8f1f9b1-60cc-11dd-b040-806d6172696f}' at mountpoint 'c:' 13:36:47 Input mask: c:\* 13:36:47 Phase 1: Analyze 13:36:47 This is an NTFS disk. 13:36:49 Finished. 13:36:49 - Total disk space: 34356477952 bytes (31.9970 gigabytes), 8387812 clusters 13:36:49 - Bytes per cluster: 4096 bytes 13:36:49 - Number of files: 27813 13:36:49 - Number of directories: 3223 13:36:49 - Total size of analyzed items: 12835758080 bytes (11.9542 gigabytes), 3133730 clusters 13:36:49 - Number of fragmented items: 272 (0.8764% of all items) 13:36:49 - Total size of fragmented items: 379191296 bytes, 92576 clusters, 2.9542% of all items, 1.1037% of disk 13:36:49 - Free disk space: 17254735872 bytes, 4212582 clusters, 50.2227% of disk 13:36:49 - Number of gaps: 627 13:36:49 - Number of small gaps: 367 (58.5327% of all gaps) 13:36:49 - Size of small gaps: 6938624 bytes, 1694 clusters, 0.0402% of free disk space 13:36:49 - Number of big gaps: 260 (41.4673% of all gaps) 13:36:49 - Size of big gaps: 17247797248 bytes, 4210888 clusters, 99.9598% of free disk space 13:36:49 - Average gap size: 6718.6316 clusters 13:36:49 - Biggest gap: 13322166272 bytes, 3252482 clusters, 77.2088% of free disk space 13:36:49 - Average end-begin distance: 611006 clusters, 7.2844% of volume size I'm doing a check on line number 18 : 13:36:49 - Number of fragmented items: 272 (0.8764% of all items) If this number is higher than FragmentedFiles in the ini it will start Defragmentation. The problem is I'm getting the next error : R:\Defrag.au3 (68) : ==> Subscript used with non-Array variable.: ConsoleWrite ( $Ret[0] & @LF ) ConsoleWrite ( $Ret^ ERROR What could be the problem. I'm using the latest version of autoit. Here is the ini file which is used by the script : [General] FragmentedFiles=100 Timeout=1 TrayIcon=1 Optimize=1
-
Searching in a text file how ?
jslegers replied to jslegers's topic in AutoIt General Help and Support
Hi, Is it also posible to use an operator in StringegExp. For example : $arResult = StringRegExp($szFileText, "(?i)friendly name = (.+)", 3) NOT StringRegExp($szFileText, "(?i)Mountpoint = none (.+)", 3) John -
Searching in a text file how ?
jslegers replied to jslegers's topic in AutoIt General Help and Support
Wow you are great thanks a lot. -
Searching in a text file how ?
jslegers replied to jslegers's topic in AutoIt General Help and Support
Hi, I have tried this but kind figure out how to use the = sign to split it in to two columns. #include <file.au3> #include <Array.au3> #include <String.au3> Local $records $file = ( @ScriptDir & "\Listdrives.txt" ) $array = $file _FileReadToArray ( $array, $records ) _ArrayDisplay ( $records, "Test Array" ) Local $results = _ArraySearch ( $records, "Friendly Name " ) _ArrayDisplay ( $results, "Results" ) -
Searching in a text file how ?
jslegers replied to jslegers's topic in AutoIt General Help and Support
How can I use that ? -
Hi, I want to make a script that can read a text file and uses the search results as variables. Here is the test file : ListUsbDrives V1.7.7 Lists attached USB drives and their USB port names for USBDLM Freeware by Uwe Sieber - www.uwe-sieber.de Current User = JSL LogonType = local Member of groups = Debugger Users, Gebruikers foutopsporing, Administrators Admin = yes MountPoint = F:\ Volume Label = PORT_APPS Volume Size = 1 GB (FAT32) Volume Name = \\?\Volume{84913105-cda4-11db-8fee-0018debf0475}\ MultiCardReader = no NoMediaNoLetter = yes Drive Type = removable drive Bus Type = USB Device Types = HotPlug Drive DevID = USBSTOR\DISK&VEN_KINGSTON&PROD_DT_ELITE_HS_2.0&REV_5.02\07A11C415350E8C0&0 Ctrl DevID = USB\VID_08EC&PID_0015\07A11C415350E8C0 Host Controller = Intel® 82801G (ICH7 Family) USB2 Enhanced Host Controller - 27CC Volume DosDevName = \Device\Harddisk3\DP(1)0-0+a Disk DosDevName = \Device\000000cc Device Number = 3 Removal Policy = surprise removal Partition Number = 1 of 1 Friendly Name = Kingston DT Elite HS 2.0 USB Version = 2.0 (high speed) USB Friendl. Name = Kingston DT Elite HS 2.0 USB Serial = 07A11C415350E8C0 USB Port Name = 5-6 MountPoint = P:\ Volume Label = Samsung External Volume Size = 250 GB (NTFS) Disk Size = 250 GB Volume Name = \\?\Volume{4362ce19-9f49-11dc-92bd-005056c00008}\ MultiCardReader = no NoMediaNoLetter = no Drive Type = fixed drive Bus Type = USB Device Types = HotPlug Drive DevID = USBSTOR\DISK&VEN_SAMSUNG&PROD_HM250JI&REV_0-08\30464D007365&0 Ctrl DevID = USB\VID_152D&PID_2338\30464D007365 Host Controller = Intel® 82801G (ICH7 Family) USB2 Enhanced Host Controller - 27CC Volume DosDevName = \Device\HarddiskVolume3 Disk DosDevName = \Device\000000c6 Device Number = 1 Removal Policy = surprise removal Partition Number = 1 of 1 Friendly Name = SAMSUNG HM250JI USB Version = 2.0 (high speed) USB Friendl. Name = JMicron USB to ATA/ATAPI Bridge USB Serial = 30464D007365 USB Port Name = 5-5 MountPoint = U:\ Volume Label = --- Volume Size = 130 MB (FAT32) Volume Name = \\?\Volume{47ec7e40-d2e0-11db-9000-00170845b81d}\ MultiCardReader = no NoMediaNoLetter = yes Drive Type = removable drive Bus Type = USB Device Types = HotPlug Drive DevID = USBSTOR\DISK&VEN_USB&PROD_FLASH_DRIVE&REV_1.12\070B000414B0B70&0 Ctrl DevID = USB\VID_1005&PID_B113\070B000414B0B70 Host Controller = Intel® 82801G (ICH7 Family) USB2 Enhanced Host Controller - 27CC Volume DosDevName = \Device\Harddisk2\DP(1)0-0+8 Disk DosDevName = \Device\000000c9 Device Number = 2 Removal Policy = surprise removal Partition Number = 1 of 1 Friendly Name = USB Flash Drive USB Version = 2.0 (high speed) USB Friendl. Name = USB Flash Drive USB Serial = 070B000414B0B70 USB Port Name = 5-4 I want to make an script that reads this file and creates variables from the names after Frinedly Name. For exapmle $var1 =Kingston DT Elite HS 2.0 $var2 = SAMSUNG HM250JI and so one. If the text has more friendly names filled it must produce more variables. If tried out this test script below but doesn't work : #include <File.au3> ;RunWait (@ComSpec & " /c ListUsbDrives.exe > usbdrives.txt", @ScriptDir, @SW_HIDE ) $Usbfile = FileOpen ( @ScriptDir & "\usbdrives.txt", 1 ) $Lines = _FileCountLines($Usbfile) ConsoleWrite ( $Usbfile & @LF ) ConsoleWrite ( $Lines & @LF ) $File = $Usbfile For $Index = 1 To $Lines $Data = FileReadLine($File,$Index) If StringInStr($Data,"Friendly Name") Then $String = StringStripWS($Data,2) $Name = StringSplit($String," ") MsgBox(-1,"",$Name[4]) EndIf Next FileClose($File) I have already made an script for removing USB drives but this one only works with P: drive and U: drive. The end result must be something like this : #include <GUIConstants.au3> ;Autoit Options AutoItSetOption ( "TrayIconHide", 1 ) ;Defining variables $driveltr = "" $prg = "RemoveDrive.exe" ;Creating GUI GUICreate ( "Select Device", 175, 105, -1, -1, $WS_BORDER ) GUISetState ( @SW_SHOW ) ;Creating radio buttons $radio1 = GUICtrlCreateRadio ( "Portable Harddisk",5 ,5 ,150 ) $radio2 = GUICtrlCreateRadio ( "USB Flash Drive",5 ,25 ,150 ) ;Creating action button $button1 = GUICtrlCreateButton ( "Remove device" ,5 ,47 ,95 ) $button2 = GUICtrlCreateButton ( "Exit" ,130 ,47, 35 ) ;Standard radio1 selected. GUICtrlSetState ( $radio1, $GUI_CHECKED ) ;Displaying GUI until it is closed. While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE or $msg = $button2 ExitLoop Case $msg = $button1 If GUICtrlRead ( $radio1 ) = 1 Then $driveltr="P:" If GUICtrlRead ( $radio2 ) = 1 Then $driveltr="U:" ;RunWait ( $prg & " " & $driveltr, @ScriptDir ) ShellExecute($prg,$driveltr,@Scriptdir) Exit EndSelect Wend Exit But this code only works when you have and USB harddisk mounted to P: and an USB stick to U:. (I use USBDLM for this). I want to make an script that works on every PC without specific drive letters voor USB Stick/Harddisks.
-
Hi, I have made a nice little script for the use with JKDefrag http://www.kessels.com/Jkdefrag/ The script runs an analyze first and then a defragmentation based on the settings in the ini file. #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Defrag.ico #AutoIt3Wrapper_outfile=Defrag.exe #AutoIt3Wrapper_Res_Description=Defrag script for JKDefrag #AutoIt3Wrapper_Res_Fileversion=1.3.1.0 #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <Date.au3> ; Setting autoit options AutoItSetOption ( "TrayMenuMode", 1 ) HotKeySet ( "#{ESC}", "Quit" ) TraySetState ( 1 ) If IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "TrayIcon", 1 ) = 0 Then TraySetState ( 2 ) EndIf ; Determing language and setting variables If @OSLang = 0409 Then $StartAn = "Starting analyze of fragmentation at " $Analy = "Analyzing " $Start = "Starting defragmentation of " $Defrag = "Defragmenting " $NoDefrag = "No defragmentation needed for " $Drive = " drive." ElseIf @OSLang = 0413 Then $StartAn = "Start met de analyse van de fragmentatie om " $Analy = "Analiseren van de " $Start = "Starten van defragmenteren " $Defrag = "Defragmenteren van de " $NoDefrag = "Geen defragmentatie nodig van " $Drive = " schijf." EndIf $Varfragini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "FragmentedFiles", 100 ) $Vartimeini = IniRead ( @ScriptDir & "\" & "Defrag.ini", "General", "Timeout", 5 ) ;ConsoleWrite($Vartimeini & @LF) ; Adding 5 minutes to the current time $sTime = _DateAdd ( 'n', $Vartimeini, _NowCalc()) $sNewTime = _DateTimeFormat ( $sTime, 4 ) ; Setting Tray Icons options. TraySetToolTip ( $StartAn & $sNewTime ) ; Waiting for x minutes. Sleep ( $Vartimeini * 60000 ) $Vardrive = DriveGetDrive( "FIXED" ) If NOT @error Then For $i = 1 to $Vardrive[0] ; Analyzing drive. TrayTip ( "", $Analy & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) $JkDefragCom = "C:\Program Files\Defrag\JkDefragCmd.exe" $JkParam = "-a 1 -l C:\Analyze_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) $Log = FileReadLine ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ,17 ) $Ret = StringRegExp($Log, ": ([0-9]{0,}),", 1, 1) FileDelete ( "C:\Analyze_" & StringTrimRight ( $Vardrive[$i], 1 ) & ".log" ) ;ConsoleWrite($Ret[0] & @LF) If $Ret[0] > $Varfragini Then ; Starting defragmentation of drive. TrayTip ( "", $Start & StringUpper ( $Vardrive[$i] ) & $Drive, 3, 1 ) Sleep ( 3000 ) TrayTip ( "", "", 0 ) TraySetToolTip ( $Defrag & StringUpper ( $Vardrive[$i] ) & $Drive ) $JkParam = "-a 3 -d 1 -s 100 -f 1 -l C:\Defrag_" & StringUpper ( StringTrimRight ( $Vardrive[$i], 1 )) & ".log " & $Vardrive[$i] ShellExecuteWait ( $JkDefragCom, $JkParam, "", "", @SW_HIDE ) Else TrayTip ( "Status", $NoDefrag & StringUpper ( $Vardrive[$i] ) & $Drive, 10, 1 ) Sleep ( 3000 ) EndIf Next EndIf ; Function Quit to stop the script. Func Quit() ProcessClose ( "JkDefragCmd.exe" ) Exit EndFunc Here is the ini file named Defrag.ini : [General] FragmentedFiles=5 Timeout=1 TrayIcon=1 Have fun with it.