
mastrboy
Active Members-
Posts
20 -
Joined
-
Last visited
mastrboy's Achievements

Seeker (1/7)
0
Reputation
-
here is a new function that can be added, it checks if a computer account exists in the active directory (_ADObjectExist does not work for this) Func _ADComputerExists($object) $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(&(objectcategory=computer)(objectclass=computer)(cn="&$object&"));cn;subtree" $objRecordSet = $ObjConnection.Execute ($strQuery) ; Retrieve the FQDN, if it exists If $objRecordSet.RecordCount = 1 Then $objRecordSet = 0 Return 1 Else $objRecordSet = 0 Return 0 EndIf EndFunc ;==>_ADObjectExists
-
thanks guys, really helped me out.. i modified it for my needs, now it only selects critical updates and writes to a log file. #include <file.au3> $logfile = @WindowsDir&"\sysprep-update.log" ; MS Ref: http://msdn2.microsoft.com/en-us/library/aa387291(VS.85).aspx $updateSession = ObjCreate("Microsoft.update.Session") $updateSearcher = $updateSession.CreateupdateSearcher() ; Searching for updates... _FileWriteLog($logfile,"Searching for updates") $searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software'") ; List of applicable items on the machine: For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) ;ConsoleWrite ($I + 1 & "> " & $update.Title & @CR) Next If $searchResult.Updates.Count = 0 Then ; There are no applicable updates _FileWriteLog($logfile,"There are no applicable updates, exited script") Exit EndIf ; Creating collection of updates to download: $updatesToDownload = ObjCreate("Microsoft.update.UpdateColl") For $I = 0 to $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) ; Only add security updates to download list If $update.MsrcSeverity Then $updatesToDownload.Add($update) _FileWriteLog($logfile,"Adding update: "&$update.Title) ; ConsoleWrite ($I + 1 & "> adding: " & $update.Title & @CR) EndIf Next If $updatesToDownload.Count = 0 Then _FileWriteLog($logfile,"There are no applicable updates, exited script") ; No security updates, so exit Exit EndIf ; Downloading updates... _FileWriteLog($logfile,"Downloading updates") $downloader = $updateSession.CreateUpdateDownloader() $downloader.Updates = $updatesToDownload $downloader.Download() ; List of downloaded updates: For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded Then _FileWriteLog($logfile,"Downloaded update: "&$update.Title) ;ConsoleWrite ($I + 1 & "> " & $update.Title & @CR) EndIf Next $updatesToInstall = ObjCreate("Microsoft.update.UpdateColl") ; Creating collection of downloaded updates to install: _FileWriteLog($logfile,"Creating collection of downloaded updates to install") For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded Then ;ConsoleWrite ($I + 1 & "> adding: " & $update.Title & @CR) _FileWriteLog($logfile,"Installing update: "&$update.Title) $updatesToInstall.Add($update) EndIf Next ; Installing updates... $installer = $updateSession.CreateUpdateInstaller() $installer.Updates = $updatesToInstall $installationResult = $installer.Install() ;Output results of install ;ConsoleWrite ("Installation Result: " & $installationResult.ResultCode ) ;ConsoleWrite ("Listing of updates installed " & "and individual installation results:" ) For $I = 0 to $updatesToInstall.Count - 1 ;ConsoleWrite ($I + 1 & "> " & $updatesToInstall.Item($I).Title & ": " & $installationResult.GetUpdateResult($I).ResultCode & @CR) _FileWriteLog($logfile,"Installed update: "&$updatesToInstall.Item($I).Title & " : " & $installationResult.GetUpdateResult($I).ResultCode) Next
-
thanks.. i'll try it out.
-
is it possible to convert this vbs script to autoit? If yes, how will i approach it? Set updateSession = CreateObject("Microsoft.Update.Session") Set updateSearcher = updateSession.CreateupdateSearcher() WScript.Echo "Searching for updates..." & vbCRLF Set searchResult = _ updateSearcher.Search("IsInstalled=0 and Type='Software'") WScript.Echo "List of applicable items on the machine:" For I = 0 To searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) WScript.Echo I + 1 & "> " & update.Title Next If searchResult.Updates.Count = 0 Then WScript.Echo "There are no applicable updates." WScript.Quit End If WScript.Echo vbCRLF & "Creating collection of updates to download:" Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl") For I = 0 to searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) WScript.Echo I + 1 & "> adding: " & update.Title updatesToDownload.Add(update) Next WScript.Echo vbCRLF & "Downloading updates..." Set downloader = updateSession.CreateUpdateDownloader() downloader.Updates = updatesToDownload downloader.Download() WScript.Echo vbCRLF & "List of downloaded updates:" For I = 0 To searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) If update.IsDownloaded Then WScript.Echo I + 1 & "> " & update.Title End If Next Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl") WScript.Echo vbCRLF & "Creating collection of downloaded updates to install:" For I = 0 To searchResult.Updates.Count-1 set update = searchResult.Updates.Item(I) If update.IsDownloaded = true Then WScript.Echo I + 1 & "> adding: " & update.Title updatesToInstall.Add(update) End If Next WScript.Echo vbCRLF & "Installing updates..." Set installer = updateSession.CreateUpdateInstaller() installer.Updates = updatesToInstall Set installationResult = installer.Install() 'Output results of install WScript.Echo "Installation Result: " & installationResult.ResultCode WScript.Echo "Listing of updates installed " & "and individual installation results:" For I = 0 to updatesToInstall.Count - 1 WScript.Echo I + 1 & "> " & _ updatesToInstall.Item(i).Title & _ ": " & installationResult.GetUpdateResult(i).ResultCode Next
-
putting it here so i don't loose it. v0.1 written with a hangover #include <GUIConstants.au3> #NoTrayIcon Opt("RunErrorsFatal", 0) ;batch packer gui for 7zip written by mastrboy with a hangover ;) ;default 7-zip location $7zip = @ProgramFilesDir & "\7-Zip\7zG.exe" ;if 7-zip not found at programfilesdir check registry for path If Not FileExists($7zip) Then $7zipreg = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip", "Path") If FileExists($7zipreg & "\7zG.exe") Then $7zip = $7zipreg & "\7zG.exe" Else MsgBox(0, "Can't locate 7-zip", "7-zip required files not found") Exit EndIf EndIf $form = GUICreate("Batch compression for 7-zip", 385, 658, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Label2 = GUICtrlCreateLabel("Folder:", 8, 8, 36, 17) $folder = GUICtrlCreateInput(@ScriptDir, 8, 25, 321, 21) $bfolder = GUICtrlCreateButton("...", 332, 24, 30, 22, 0) $Label3 = GUICtrlCreateLabel("Output folder:", 8, 55, 70, 17) $outputfolder = GUICtrlCreateInput(@ScriptDir, 8, 74, 321, 21) $boutputfolder = GUICtrlCreateButton("...", 332, 73, 30, 22, 0) $Label4 = GUICtrlCreateLabel("Archive format:", 48, 144, 75, 17) $Label1 = GUICtrlCreateLabel("Compression Level:", 32, 176, 96, 17) $Group1 = GUICtrlCreateGroup("Options", 8, 112, 361, 209) $Label5 = GUICtrlCreateLabel("Filetype:", 80, 264, 43, 17) $ifileext = GUICtrlCreateInput("*.*", 136, 264, 153, 21) $bsearch = GUICtrlCreateButton("Search", 295, 262, 55, 25, 0) $format = GUICtrlCreateCombo("", 136, 144, 153, 25) $level = GUICtrlCreateCombo("", 136, 176, 153, 25) $delete = GUICtrlCreateCheckbox("Delete files", 136, 208, 161, 17) $recycle = GUICtrlCreateCheckbox("Move files to Recycle bin", 136, 232, 135, 17) $status = GUICtrlCreateList("", 16, 368, 345, 214, BitOR($WS_BORDER,$WS_VSCROLL)) $start = GUICtrlCreateButton("Start", 8, 608, 81, 33, 0) $exit = GUICtrlCreateButton("Exit", 208, 608, 81, 33, 0) $Group2 = GUICtrlCreateGroup("Status", 8, 328, 361, 273) $help = GUICtrlCreateButton("Help", 296, 608, 73, 33, 0) $progress = GUICtrlCreateProgress(16, 344, 337, 17) GUICtrlSetTip($help, "Help") GUICtrlSetState($start, $GUI_DISABLE) GUICtrlSetState($delete, $GUI_DISABLE) GUICtrlSetState($recycle, $GUI_DISABLE) GUICtrlSetData($format, "7z|Gzip|Zip", "Zip") GUICtrlSetData($level, "Normal|Maximum|Ultra", "Maximum") GUISetState(@SW_SHOW) While 1 ;check to make sure delete and recycle is not selected at the same time $del = GUICtrlRead($delete) $rec = GUICtrlRead($recycle) If $del = "1" And $rec = "1" Then MsgBox(48, "Wrong options", "You can't both delete and move to recycle bin") GUICtrlSetState($delete, $GUI_UNCHECKED) GUICtrlSetState($recycle, $GUI_UNCHECKED) EndIf ;make some variables from gui $fileext = GUICtrlRead($ifileext) $gfolder = GUICtrlRead($folder) ;folder \ fix If StringRight($gfolder, 1) = "\" Then ; Else $gfolder = $gfolder & "\" EndIf $goutputfolder = GUICtrlRead($outputfolder) ;folder \ fix If StringRight($goutputfolder, 1) = "\" Then ; Else $goutputfolder = $goutputfolder & "\" EndIf ;look for actions $nMsg = GUIGetMsg() Switch $nMsg Case $bfolder ;display folder select dialog $folderselect = FileSelectFolder("Choose folder to search for files", "", 4, @ScriptDir) If $folderselect Then GUICtrlSetData($folder, $folderselect) Case $boutputfolder ;display folder select dialog $outfolderselect = FileSelectFolder("Choose output folder", "", 5, @ScriptDir) If $outfolderselect Then GUICtrlSetData($outputfolder, $outfolderselect) Case $bsearch ;check for valid folder to search in If StringInStr(FileGetAttrib($gfolder), "D") Then ;search for files $search = FileFindFirstFile($gfolder & $fileext) ;check to see if there is any nds files in the folder previusly selected If $search = -1 Then MsgBox(48, "Error", "No files matching " & $fileext & " found in " & $gfolder) GUICtrlSetState($start, $GUI_DISABLE) ; Close the search handle FileClose($search) Else $i = "0" While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If Not StringInStr(FileGetAttrib($gfolder & $file), "D", 1) Then $i = $i + 1 EndIf WEnd GUICtrlSetData($status, "Found " & $i & " File(s)|") GUICtrlSetState($start, $GUI_ENABLE) $progressmax = $i EndIf FileClose($search) Else MsgBox(48, "Invalid folder", "Folder is invalid, or does not exist") EndIf Case $start ;compression level variable check $glevel = GUICtrlRead($level) Switch $glevel Case "Normal" $clevel = "5" Case "Maximum" $clevel = "7" Case "Ultra" $clevel = "9" EndSwitch ;command processing $gformat = GUICtrlRead($format) Switch $gformat Case "7z" $ext = ".7z" Case "Gzip" $ext = ".gz" Case "Zip" $ext = ".zip" EndSwitch ;check output folder If FileExists($goutputfolder) And StringInStr(FileGetAttrib($goutputfolder), "D") Then $search = FileFindFirstFile($gfolder & $fileext) $i = 0 While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If Not StringInStr(FileGetAttrib($gfolder & $file), "D", 1) Then $fullfile = $gfolder & $file ;grr, took me ages to figure out this ugly regexp.. i hate regexp!! $outfile = StringRegExpReplace($file, "\.(.*)", $ext) $fulloutfile = $goutputfolder & $outfile Switch $gformat Case "7z" $command = $7zip & " a -mx" & $clevel & " -t7z """ & $fulloutfile & """" & " """ & $fullfile & """" Case "Gzip" $command = $7zip & " a -mx" & $clevel & " -tgzip """ & $fulloutfile & """" & " """ & $fullfile & """" Case "Zip" $command = $7zip & " a -mx" & $clevel & " -tzip """ & $fulloutfile & """" & " """ & $fullfile & """" EndSwitch GUICtrlSetState($start, $GUI_DISABLE) $i = $i + 1 $progressset = $i / $progressmax * 100 GUICtrlSetData($progress,int($progressset)) $run = RunWait($command) Switch $run Case 0 GUICtrlSetData($status, "Compressed - "&$file & "|") Case 1 GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "Warning (Non fatal error(s)). For example, some files were locked by other application during compressing. So they were not compressed.|") ExitLoop Case 2 GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "Fatal error|") ExitLoop Case 7 GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "Command line error|") ExitLoop Case 8 GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "Not enough memory for operation|") ExitLoop Case 255 GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "canceled|") ExitLoop Case Else GUICtrlSetState($start, $GUI_ENABLE) GUICtrlSetData($status, "unknown error|") ExitLoop EndSwitch GUICtrlSetState($start, $GUI_ENABLE) EndIf WEnd FileClose($search) Else MsgBox(48, "Invalid output folder", "Output folder does not exist or is not a folder!") EndIf Case $help MsgBox(64,"hmm","There should be some help here, but my head hurts to much to write it right now :P") Case $exit Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd se attachement for compiled batchpacker_gui.exe
-
little fix to _ADIsMemberOf: If you try to check a group and the group don't exist, you end up with a object error like this: C:\test.au3 (28) : ==> Variable must be of type "Object".: $ismember = $objgroup.IsMember ("LDAP://" & $strHostServer & "/" & _ADSamAccountNameToFQDN($user)) $ismember = $objgroup^ ERROR to fix this change the function to: Func _ADIsMemberOf($group, $user) $ObjGroup = ObjGet("LDAP://" & $strHostServer & "/" & _ADSamAccountNameToFQDN($group)) ;check if there is and object to check, else return 0 as the group does not exist If IsObj($objgroup) Then $ismember = $objgroup.IsMember ("LDAP://" & $strHostServer & "/" & _ADSamAccountNameToFQDN($user)) Return -$ismember Else Return 0 EndIf EndFunc ;==>_ADIsMemberOf
-
i putting it on this forum so i don't loose it Func _uptime(ByRef $iDays, ByRef $iHours, ByRef $iMins, ByRef $iSecs) $iTicks = DllCall("kernel32.dll", "long", "GetTickCount") $iTicks = $iTicks[0] If Number($iTicks) > 0 Then $iTicks = Round($iTicks / 1000) $iDays = Int($iTicks / 86400) $iHours = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $iMins = Int($iTicks / 60) $iSecs = Round(Mod($iTicks, 60)) Return 1 ElseIf Number($iTicks) = 0 Then $iDays = 0 $iHours = 0 $iTicks = 0 $iMins = 0 $iSecs = 0 Return 1 Else SetError(1) Return 0 EndIf EndFunc ;==>_uptimeoÝ÷ Ú+wöƦ¡Øçoz»"¢z¶'$²Ú-gºØën®{-ë©¶)µë-yÚ'Æ6Ç«½êðÚMìz»ÞìZ^jëh×6Dim $idays Dim $ihours Dim $imins Dim $isecs _uptime($idays,$ihours,$imins,$isecs) MsgBox(0,"Uptime","Days: "&$idays&" Hours: "&$ihours&" mins: "&$imins&" secs: "&$isecs) exit
-
great, the newest version fixed my problem with: _ADGetObjectAttribute thanks again
-
thanks. just the functions i was looking for
-
Convert Batch Script To Auto-it Gui
mastrboy replied to mastrboy's topic in AutoIt GUI Help and Support
thanks i'll check it out -
-
-
php highlight AutoIT syntax/language?
mastrboy replied to mastrboy's topic in AutoIt General Help and Support
- -
php highlight AutoIT syntax/language?
mastrboy replied to mastrboy's topic in AutoIt General Help and Support
- -
php highlight AutoIT syntax/language?
mastrboy replied to mastrboy's topic in AutoIt General Help and Support
-