Leaderboard
Popular Content
Showing content with the highest reputation on 05/28/2018 in all areas
-
This function is based on _WinAPI_UniqueHardwareID() in WinAPIDiag.au3. The flags which can be used in this function are exactly the same flags as in _WinAPI_UniqueHardwareID(). Any problems please post below. Thanks. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetHardwareID ; Description ...: Generates a unique hardware identifier (ID) for the local computer. ; Syntax ........: _GetHardwareID([$iFlags = Default]) ; Parameters ....: $iFlags - [optional] The flags that specifies what information would be used to generate ID. ; This parameter can be one or more of the following values. ; ; $UHID_MB (0) ; Uses information about your motherboard. This flag is used by default regardless of whether specified or not. ; ; $UHID_BIOS (1) ; Uses information about the BIOS. ; ; $UHID_CPU (2) ; Uses information about the processor(s). ; ; $UHID_HDD (4) ; Uses information about the installed hard drives. Any change in the configuration disks will change ID ; returned by this function. Taken into account only non-removable disks. ; ; $UHID_All (7) ; The sum of all the previous flags. Default is $UHID_MB (0). ; ; $bIs64Bit - [optional] Search the 64-bit section of the registry. Default is dependant on AutoIt bit version. ; Note: 64-bit can't be searched when running the 32-bit version of AutoIt. ; Return values..: Success - The string representation of the ID. @extended returns the value that contains a combination of flags ; specified in the $iFlags parameter. If flag is set, appropriate information is received successfully, ; otherwise fails. The function checks only flags that were specified in the $iFlags parameter. ; Failure - Null and sets @error to non-zero. ; Author.........: guinness with the idea by Yashied (_WinAPI_UniqueHardwareID() - WinAPIDiag.au3) ; Modified ......: Additional suggestions by SmOke_N. ; Remarks .......: The constants above can be found in APIDiagConstant.au3. It also requires StringConstants.au3 and Crypt.au3 to be included. ; Example........: Yes ; =============================================================================================================================== Func _GetHardwareID($iFlags = Default, $bIs64Bit = Default) Local $sBit = @AutoItX64 ? '64' : '' If IsBool($bIs64Bit) Then ; Use 64-bit if $bIs64Bit is true and AutoIt is a 64-bit process; otherwise 32-bit $sBit = $bIs64Bit And @AutoItX64 ? '64' : '' EndIf If $iFlags == Default Then $iFlags = $UHID_MB EndIf Local $aSystem = ['Identifier', 'VideoBiosDate', 'VideoBiosVersion'], _ $iResult = 0, _ $sHKLM = 'HKEY_LOCAL_MACHINE' & $sBit, $sOutput = '', $sText = '' For $i = 0 To UBound($aSystem) - 1 $sOutput &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\', $aSystem[$i]) Next $sOutput &= @CPUArch $sOutput = StringStripWS($sOutput, $STR_STRIPALL) If BitAND($iFlags, $UHID_BIOS) Then Local $aBIOS = ['BaseBoardManufacturer', 'BaseBoardProduct', 'BaseBoardVersion', 'BIOSVendor', 'BIOSReleaseDate'] $sText = '' For $i = 0 To UBound($aBIOS) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\BIOS\', $aBIOS[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_BIOS $sOutput &= $sText EndIf EndIf If BitAND($iFlags, $UHID_CPU) Then Local $aProcessor = ['ProcessorNameString', '~MHz', 'Identifier', 'VendorIdentifier'] $sText = '' For $i = 0 To UBound($aProcessor) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\CentralProcessor\0\', $aProcessor[$i]) Next For $i = 0 To UBound($aProcessor) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\CentralProcessor\1\', $aProcessor[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_CPU $sOutput &= $sText EndIf EndIf If BitAND($iFlags, $UHID_HDD) Then Local $aDrives = DriveGetDrive('FIXED') $sText = '' For $i = 1 To UBound($aDrives) - 1 $sText &= DriveGetSerial($aDrives[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_HDD $sOutput &= $sText EndIf EndIf Local $sHash = StringTrimLeft(_Crypt_HashData($sOutput, $CALG_MD5), StringLen('0x')) If Not $sHash Then Return SetError(1, 0, Null) EndIf Return SetExtended($iResult, StringRegExpReplace($sHash, '([[:xdigit:]]{8})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{12})', '{\1-\2-\3-\4-\5}')) EndFunc ;==>_GetHardwareID Example use of Function: #include <APIDiagConstants.au3> #include <Crypt.au3> #include <StringConstants.au3> Local $sUniqueID = _GetHardwareID($UHID_All) ConsoleWrite('UniqueID: ' & $sUniqueID & @CRLF & _ 'Flags used: ' & @extended & @CRLF)1 point
-
Since the Shift-NUMPAD0 combination equals the keyboard INSERT-Key use HotKeySet("^{INS}","Group6)") for setting Shift-Ctrl-Numpad0 A-Jay1 point
-
Test this one: #include <outlookex.au3> #include <Array.au3> $oOL = _OL_Open() _OL_ErrorNotify(2) $aAddressLists = _OL_AddressListGet($oOL) $aGALMembers = _OL_AddressListMemberGet($oOL, $aAddressLists[1][2]) ; <== Replace 1 with the index of your GAL in $aAddressLists For $i = 1 To $aGALMembers[0][0] ; Exchange user that belongs to the same or a different Exchange forest If $aGALMembers[$i][2] = $olExchangeUserAddressEntry Or $aGALMembers[$i][2] = $olExchangeRemoteUserAddressEntry Then ConsoleWrite("Exchange: " & $aGALMembers[$i][4].Name & @CRLF) ; Address entry in an Outlook Contacts folder Else ConsoleWrite("No Exchangegroup: " & $aGALMembers[$i][1] & @CRLF) EndIf ; Exitloop Next _OL_Close($oOL) Properties for an Exchange UserAddressEntry can be found here: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/exchangeuser-object-outlook1 point
-
Need to start the tool from last termination point
Earthshine reacted to jchd for a topic
Rather than adding a dirty hack to bad code, fix your program ny testing for possible runtime errors and handle them gracefully.1 point -
Seems like not image file in folder. Try this ... _GDIPlus_Startup() For $i = 1 To $imagelist[0] $sPath = $imagelist[$i] $hImage = _GDIPlus_ImageLoadFromFile($sPath) If @error Then ContinueLoop $hImage_Negative = _GDIPlus_BitmapCreateNegative($hImage) $sName = StringMid($sPath, StringInStr($sPath, "\", 1, -1) + 1) _GDIPlus_ImageSaveToFile($hImage_Negative, @ScriptDir & "\Images\GDIplus_" & $sName) _GDIPlus_ImageDispose($hImage_Negative) _GDIPlus_ImageDispose($hImage) Next _GDIPlus_Shutdown() ...1 point
-
I figured that it would trigger UAC since it basically did the same as running with the #RequireAdmin directive. I don't think the script will continue to run while the UAC prompt is waiting unless you spawned another script to actually do the clicking of the button. If the main goal is to be able to run without prompting, and your users are already local admins, it just seems easier to modify the one registry setting to automatically elevate for admins without prompting. It's a one-time modification for each workstation. If you plan on being able to run additional scripts that require elevation in the future, then it seems like the best solution. Good luck.1 point
-
I updated the snippet above. You weren't capturing the StdErr correctly. Now you will see the WMIC error messages, if they exist.1 point
-
Although this doesn't require elevation, it works for me. Also, changed Run() to use $STDERR_MERGED. That way you will see the WMIC error message, if one exists. #include <Constants.au3> #include <WinAPI.au3> elevate_to_run_with_admin_token() $sOutput = _GetDOSOutput("wmic csproduct get /format:list") MsgBox(0,"Output",$sOutput) $sOutput = _GetDOSOutput("wmic /namespace:\\root\dcim\sysman path dcim_biosenumeration where(attributename like '%Microphone%') get currentvalue") MsgBox(0,"Output",$sOutput) ;========================================================================== ; This assumes that the user is a local admin. ; Do NOT use #RequireAdmin if using this method of elevation ;========================================================================== Func elevate_to_run_with_admin_token() Local $sErrorMsg = "" Local $iPid = 0 ;Run with "runas" verb in order request full Admin token (in Windows Vista and Higher - UAC-enabled OSes). If (Not IsAdmin()) And (Not StringRegExp(@OSVersion, "_(?:XP|2000|2003))")) Then $iPid = ShellExecute(@AutoItExe, $CmdLineRaw, @ScriptDir, "runas") If $iPid Then Exit Else $sErrorMsg = "ERROR: Unable to elevate to Admin due to UAC. " & _WinAPI_GetLastErrorMessage() MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", $sErrorMsg) Exit -1 EndIf EndIf MsgBox( _ $MB_ICONINFORMATION + $MB_TOPMOST, _ "INFO", _ StringFormat("Elevated status = %s", (IsAdmin())?("TRUE"):("FALSE")) _ ) Return EndFunc Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_MERGED) ; <-- changed to $STDERR_MERGED While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput1 point
-
@horphi Probably need to check the value of @error after the call to _WD_Window. I'll have to do some testing, but would have thought that the earlier call to _WD_ExecuteScript would have failed. Edit: Fixed _WD_ExecuteScript so that it properly sets @error1 point
-
You can try the snippet below. It is a different method of elevation that works if your users are local admins. Because you haven't implement the suppressing of UAC prompts for local admins, it may trigger the prompt just as if you had added #RequireAdmin. Try it out and see if it works for you. Basically, it checks to see if you are running the script with elevated privileges. If not, it will re-launch itself using the ShellExecute function with the "runas" verb in order to request elevation. By the way, I didn't check it for errors so you may have to tweak it a tad. #include <Constants.au3> #include <WinAPI.au3> elevate_to_run_with_admin_token() $WmiCommand = ( _GetDOSOutput("wmic /namespace:\\root\dcim\sysman path dcim_biosenumeration where(attributename like '%%Microphone%%') get currentvalue") & @CRLF) ;========================================================================== ; This assumes that the user is a local admin. ; Do NOT use #RequireAdmin if using this method of elevation ;========================================================================== Func elevate_to_run_with_admin_token() Local $sErrorMsg = "" Local $iPid = 0 ;Run with "runas" verb in order request full Admin token (in Windows Vista and Higher - UAC-enabled OSes). If (Not IsAdmin()) And (Not StringRegExp(@OSVersion, "_(?:XP|2000|2003))")) Then $iPid = ShellExecute(@AutoItExe, $CmdLineRaw, @ScriptDir, "runas") If $iPid Then Exit Else $sErrorMsg = "ERROR: Unable to elevate to Admin due to UAC. " & _WinAPI_GetLastErrorMessage() MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", $sErrorMsg) Exit -1 EndIf EndIf MsgBox( _ $MB_ICONINFORMATION + $MB_TOPMOST, _ "INFO", _ StringFormat("Elevated status = %s", (IsAdmin())?("TRUE"):("FALSE")) _ ) Return EndFunc Func _GetDOSOutput($sCommand) Local $iPID, $sOutput = "" $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc ;==>_GetDOSOutput1 point
-
TreeVIew Check only Child Selected
behdadsoft reacted to LarsJ for a topic
It should be: Case $iStart + 1 To $iEnd - 1 You are only interested in treeview item controls. $iStart and $iEnd are dummy controls, so let's exclude both. The level is the number of vertical lines in front of a treeview item. Here all parent items are level 1 and all child items are level 2.1 point -
AI is a complex concept and usually is a mixture of many algorithms combined. For what you need a good start would be to play with levenshtein distance. This is an algorithm to check the similarities of strings.1 point
-
Hello. Try this. #include <Date.au3> Local $today=_DateToDayValue(@YEAR,@MON,@MDAY),$Y, $M, $D Local $tomorrow=_DayValueToDate($today+1, $Y, $M, $D) $tomorrow= StringFormat("%02i/%02i/%04i", $M, $D, $Y) ConsoleWrite($tomorrow & @CRLF) Saludos1 point
-
need to execute cmd commands
DynamicRookie reacted to Gianni for a topic
to which of those two you belong.... lol1 point -
Need to start the tool from last termination point
Earthshine reacted to Ade1234 for a topic
My code is working fine but I want to avoid rework of my program after a unexpected termination.0 points