obfuscatedv Posted January 10, 2014 Share Posted January 10, 2014 I am querying a group of computers to see if they use a specific homepage for Internet Explorer. This is located at HKEY_Current_UserSoftwareMicrosoftInternet ExplorerMain and the registry name I believe for IE is "Start Page." Ideally, if it finds the start page URL that I list in the script, I want it to return an exit code. Not sure of best way to write it though. Something like... If StartPage = xxx, return exit code 1 If StartPage = yyy, return exit code 2 If StartPage = zzz, return exit code 3 else return exit code 0 Along those lines. Any help is appreciated, I'm sort of stuck :/ Link to comment Share on other sites More sharing options...
Solution l3ill Posted January 10, 2014 Solution Share Posted January 10, 2014 Hi obfuscatedv Welcome to unstuck: $searchSite = "http://www.autoitscript.com/site/" $startPage = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page") ConsoleWrite("$startPage = " & $startPage & @CRLF) If $searchSite = $startPage Then MsgBox(0, "Success", "Yay it worked") Else MsgBox(0, "Fail", "Different Page") Endif Have fun! Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 10, 2014 Author Share Posted January 10, 2014 That is perfect. Just what I was looking for. Thanks a lot! Link to comment Share on other sites More sharing options...
l3ill Posted January 10, 2014 Share Posted January 10, 2014 Super! Glad it worked. And here it is with the new Ternary syntax ( been wanting to try this on something ) $searchSite = "http://www.autoitscript.com/site/" $startPage = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page") ConsoleWrite("$startPage = " & $startPage & @CRLF) MsgBox(0, "Ternary", ($searchSite = $startPage) ? "Yay it worked" : "Different Page") My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
jdelaney Posted January 10, 2014 Share Posted January 10, 2014 (edited) You can script the query, locally like this...requires you to first map the external system...you would need to parse the output: #include <Constants.au3> Local $sPage $ip = "Your IP" $user = "domain\user" $password = "password" RunWait(@ComSpec & " /c net use \\" & $ip & "\c$ /USER:" & $user & " " & $password,"",@SW_HIDE) $iPID = Run(@ComSpec & " /c reg query ""\\" & $ip & "\HKLM\Software\Microsoft\Internet Explorer\main"" /v ""start page""","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($iPID) If @error Then ExitLoop If $line Then ConsoleWrite($line & @CRLF) WEnd While 1 $line = StderrRead($iPID) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd RunWait(@ComSpec & " /c net use \\" & $ip & "\c$ /delete","",@SW_HIDE) Even better, this will output just the page: $iPID = Run(@ComSpec & " /c for /f ""tokens=4"" %a in ('reg query ""\\172.27.101.12\HKLM\Software\Microsoft\Internet Explorer\main"" /v ""start page""') Do echo %a","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Using the above to output just the page to variable = $sPage: #include <Constants.au3> Local $sPage $ip = "Your IP" $user = "domain\user" $password = "password" RunWait(@ComSpec & " /c net use \\" & $ip & "\c$ /USER:" & $user & " " & $password,"",@SW_HIDE) ;~ $iPID = Run(@ComSpec & " /c reg query ""\\" & $ip & "\HKLM\Software\Microsoft\Internet Explorer\main"" /v ""start page""","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) $iPID = Run(@ComSpec & " /c echo off & for /f ""tokens=4"" %a in ('reg query ""\\" & $ip & "\HKLM\Software\Microsoft\Internet Explorer\main"" /v ""start page""') Do echo %a","",@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($iPID) If @error Then ExitLoop If $line Then $sPage = StringRegExpReplace($line,"[\r\n]+","") WEnd ConsoleWrite($sPage & @CRLF) While 1 $line = StderrRead($iPID) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd RunWait(@ComSpec & " /c net use \\" & $ip & "\c$ /delete","",@SW_HIDE) Then, just loop through all your stations, you can run anywhere...the For loop is kind of 'dumb' if there is a " " in the page, it will not return the whole thing...luckily, i think spaces are turned int %20, or something like that. Using just AutoIT function (even easier): $ip = "IPOfComp" $user = "Domain\User" ; If user is a local user, and not domain, then "\user" $password = "password" If DriveMapAdd("","\\" & $ip & "\c$",0,$user,$password) Then ConsoleWrite(RegRead("\\" & $ip & "\HKLM\Software\Microsoft\Internet Explorer\main","start page") & @CRLF) DriveMapDel("\\" & $ip & "\c$") Else ConsoleWrite("Unable to map drive " & @extended & @CRLF) EndIf Edited January 10, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
AdamUL Posted January 10, 2014 Share Posted January 10, 2014 (edited) Here is a way you can get all the user start pages for all profiles on a PC. It uses the very nice >HKCUReg UDF. #include <HKCUReg.au3> #include <Array.au3> Global $sSearchSite = "http://www.autoitscript.com/site/" Global $aUsersStartPage = _GetIEStartPageAllUsers("COMPUTERNAME") For $i = 0 To UBound($aUsersStartPage) - 1 Step 1 If $aUsersStartPage[$i][1] = $sSearchSite Then ConsoleWrite($aUsersStartPage[$i][0] & " has the correct page." & @LF) Else ConsoleWrite($aUsersStartPage[$i][0] & " has the incorrect page." & @LF) EndIf Next Func _GetIEStartPageAllUsers($sComputer) Local $aStartPage = _HKCU_Read("\\\" & $sComputer & "\Software\Microsoft\Internet Explorer\Main", "Start Page") ;~ _ArrayDisplay($aStartPage, "$aStartPage") ;For testing. ReDim $aStartPage[UBound($aStartPage) - 1][UBound($aStartPage, 2) - 2] ;Remove Default profile and non-used columns. ;~ _ArrayDisplay($aStartPage, "$aStartPage") ;For testing. _ArrayDelete($aStartPage, 0) ;Remove row count row. ;~ _ArrayDisplay($aStartPage, "$aStartPage") ;For testing. Return $aStartPage EndFunc Adam Edited January 10, 2014 by AdamUL Link to comment Share on other sites More sharing options...
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