Syed23 Posted August 24, 2011 Posted August 24, 2011 (edited) Hi Friends, This is my first function which i have created for my own process.This will work on both Windows 7 and Vista machines. This is to retrive the status of Bitlocker. Please check it on Vista or Windows 7 machine and let me know how it works.. Also let me know if i have to update my function expandcollapse popup#include-once ;=============================================================================== ; Description: Returns the Bitlocker status of the machine. ; Parameter(s): $strComputer - By Reference - Computer name. ; Requirement(s): None ; Return Value(s): On Success - Returns "YES" or "EncryptionPercentage" or "NO". ; Author : Syed Ibrahim ; ;=============================================================================== Func Bitlock($strComputer) Global $objItem,$protection, $ConversionStatus,$protectionstatus,$colItems,$objWMIService $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", 48) $protectionstatus = "NO" If IsObj($colItems) Then For $objItem In $colItems $objItem.GetProtectionStatus($protection) $objItem.GetConversionStatus ($ConversionStatus) If $protection = 1 Then $protectionstatus = "YES" ElseIf $ConversionStatus > 0 Then $protectionstatus = "EncryptionPercentage" EndIf ExitLoop Next EndIf Return $protectionstatus EndFunc ;=============================================================================== ; Description: Returns the TPM PIN status of the machine. ; Parameter(s): $strComputer - By Reference - Computer name. ; Return Value(s): On Success - Returns TRUE or FALSE. ; =============================================================================== Func Pin($strComputer) Global $objWMIService, $colItems,$Return $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL",48) $Return = -1 ; Result will return either 0 or 1. To get the change value assigning If IsObj($colItems) Then For $objItem in $colItems $objItem.IsKeyProtectorAvailable(4, $Return) Next EndIf Return $Return EndFunc Example Script: #RequireAdmin #include"Bit.au3" MsgBox(0,"Bitlocker Status",Bitlock(@ComputerName)) Note: #RequireAdmin is mandatory inorder to work! Edited August 24, 2011 by Syed23 Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
Moderators SmOke_N Posted August 24, 2011 Moderators Posted August 24, 2011 I assume this was intended for the Example Script Forum. Moving. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
JohnOne Posted August 24, 2011 Posted August 24, 2011 Not sure that a global variable can be declared in local scope Probably best to use 'Local' AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
MvGulik Posted August 24, 2011 Posted August 24, 2011 Not sure that a global variable can be declared in local scope.Yes is can. Not advised of course in relation to good coding practice. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
Syed23 Posted August 24, 2011 Author Posted August 24, 2011 Hi Friends, Thanks for the suggesstions... But i am facing an issue in this! If i add this function and if i run it on XP machine i am facing below error. Can someone tell me why? Variable must be of type "Object" Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
guinness Posted August 24, 2011 Posted August 24, 2011 (edited) Please re-read the requirements of Win32_EncryptableVolume Class and have a look at _WinAPI_OSVersion() in WinAPIEx.au3 by Yashied to check if the OS is greater or equal to 6.0 or look at @OSVersion. Edited August 24, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Syed23 Posted August 24, 2011 Author Posted August 24, 2011 Please re-read the requirements of Win32_EncryptableVolume Class and have a look at _WinAPI_OSVersion() in WinAPIEx.au3 by Yashied to check if the OS is greater or equal to 6.0 or look at @OSVersion.i have added the @OSVERSION check on my main program Guinness.... But the think is not even it reaches that point i am getting the same error message.Also i tried to use OBfuscator... but it shows me lot of error message on MY "SQL" , "WINAPI" and some other UDF's...... i am going mad what going wron on my machine... Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]
guinness Posted August 24, 2011 Posted August 24, 2011 (edited) Here >> I'm using IsObj() to check it's an Object and you should've put @OSVersion at the start of the function. expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include-once ;=============================================================================== ; Description: Returns the Bitlocker status of the machine. ; Parameter(s): $sComputerName - By Reference - Computer name. ; Requirement(s): None ; Return Value(s): On Success - Returns "YES" or "EncryptionPercentage" or "NO". ; Author : Syed Ibrahim ; ;=============================================================================== Func Bitlock($sComputerName) Local $iConversionStatus, $iProtection, $oColItems, $oItem, $oWMIService, $sProtectionStatus $oWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If IsObj($oWMIService) = 0 Then Return SetError(1, 0, -1) EndIf $oColItems = $oWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", 48) $sProtectionStatus = "NO" If IsObj($oColItems) Then For $oItem In $oColItems $oItem.GetProtectionStatus($iProtection) $oItem.GetConversionStatus($iConversionStatus) If $iProtection = 1 Then $sProtectionStatus = "YES" ElseIf $iConversionStatus > 0 Then $sProtectionStatus = "EncryptionPercentage" EndIf ExitLoop Next EndIf Return $sProtectionStatus EndFunc ;==>Bitlock ;=============================================================================== ; Description: Returns the TPM PIN status of the machine. ; Parameter(s): $sComputerName - By Reference - Computer name. ; Return Value(s): On Success - Returns TRUE or FALSE. ; =============================================================================== Func Pin($sComputerName) Local $oColItems, $oWMIService, $sReturn $oWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If IsObj($oWMIService) = 0 Then Return SetError(1, 0, -1) EndIf $oColItems = $oWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume", "WQL", 48) $sReturn = -1 ; Result will return either 0 or 1. To get the change value assigning If IsObj($oColItems) Then For $oItem In $oColItems $oItem.IsKeyProtectorAvailable(4, $sReturn) Next EndIf Return $sReturn EndFunc ;==>Pin Edited August 25, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
JohnOne Posted August 24, 2011 Posted August 24, 2011 Yes is can. Not advised of course in relation to good coding practice.Never new that, I see the func has to be called first though, before the var is used.Cheers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now