twbradio Posted November 7, 2005 Share Posted November 7, 2005 I have a piece of code that works OK in VB but is not working in AutoIT and I was wondering if you could give me a hand. Below is a functional code snippet from the larger script that includes the problem code. Perhaps someone that is better at WMI than me can see where the issue is. $report = "c:\test.txt" $strComputer = "." $objFile = FileOpen ($report, 2) $objWMIService2 = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\"&$strComputer&"\root\CIMV2\Applications\MicrosoftIE") $colIESettings2 = $objWMIService2.ExecQuery ("Select * from MicrosoftIE_ConnectionSettings") For $strIESetting in $colIESettings2 FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Autoconfiguration URL:</td>"&@CRLF ) FileWrite ( $objFile, "<td>"&$strIESetting.AutoConfigURL&"</td>"&@CRLF ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Proxy Server:</td>"&@CRLF ) FileWrite ( $objFile, "<td>" ) $PS = StringSplit($strIESetting.ProxyServer, ";") For $settinG in $PS FileWrite ( $objFile, $settinG&"<br>"&@CRLF ) Next FileWrite ( $objFile, "<\td>" ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) Next FileClose ( $objFile ) The output of the code is in html, so if you get it working the output will be the middle of a table that is defined earlier in my script. Thanks - Tom Anyone have a TRS 80 Model III for sale? Link to comment Share on other sites More sharing options...
twbradio Posted November 7, 2005 Author Share Posted November 7, 2005 I have auto setup here at work... maybe that is why I get no data...Lar.edit: yes even the vbs returns no data...Lar.We have an auto script here as well, but the script should still do something - if you put a msgbox inside the for - in loop it never trips. I am working on trimming the VB script into a similar code that does work.Tom Anyone have a TRS 80 Model III for sale? Link to comment Share on other sites More sharing options...
jpm Posted November 7, 2005 Share Posted November 7, 2005 this code is certainly wrong$PS = StringSplit($strIESetting.ProxyServer, ";") For $settinG in $PS FileWrite ( $objFile, $settinG&"<br>"&@CRLF ) Next $PS is an array the first element being the number of substring. So the $settinG will generate a filewrite for this first element which is obviously what you don't intend to do. Change toFor $settinG = 1 to $PS[0] Filewrite($objFile, $PS[$settinG] & "<br>"& @CRLF) next I am not familiar with VB but the StringSplit must be different Link to comment Share on other sites More sharing options...
twbradio Posted November 7, 2005 Author Share Posted November 7, 2005 this code is certainly wrong$PS = StringSplit($strIESetting.ProxyServer, ";") For $settinG in $PS FileWrite ( $objFile, $settinG&"<br>"&@CRLF ) Next$PS is an array the first element being the number of substring. So the $settinG will generate a filewrite for this first element which is obviously what you don't intend to do.Change toFor $settinG = 1 to $PS[0] Filewrite($objFile, $PS[$settinG] & "<br>"& @CRLF) nextI am not familiar with VB but the StringSplit must be different I almost pulled that bit out since I haddn't massaged it much from the VB to AU3 conversion tool that I ran on the original script - at leat this indicates that if I can ever get the For - IN loop to do anything that I will at least have an error to let me know its working Anyone have a TRS 80 Model III for sale? Link to comment Share on other sites More sharing options...
twbradio Posted November 7, 2005 Author Share Posted November 7, 2005 I almost pulled that bit out since I haddn't massaged it much from the VB to AU3 conversion tool that I ran on the original script - at leat this indicates that if I can ever get the For - IN loop to do anything that I will at least have an error to let me know its workingOK - I see what the VB script is doing, and this looks like a piece of junk code that was never removed, I'll post the working code as soon as I get it flushed out. Thank you all.Tom Anyone have a TRS 80 Model III for sale? Link to comment Share on other sites More sharing options...
twbradio Posted November 7, 2005 Author Share Posted November 7, 2005 OK, here is the correct WMI call for the IE proxy settingsTom#include <Array.au3> $report = "c:\test.txt" $strComputer = "." $objFile = FileOpen ($report, 2) $objWMIService2 = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\"&$strComputer&"\root\CIMV2\Applications\MicrosoftIE") $colIESettings3 = $objWMIService2.ExecQuery ("Select * from MicrosoftIE_LANSettings") For $strIESetting2 in $colIESettings3 FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Auto-Proxy URL:</td>"&@CRLF ) FileWrite ( $objFile, "<td>"&$strIESetting2.AutoConfigURL&"</td>"&@CRLF ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Auto-Proxy detection mode:</td>"&@CRLF ) FileWrite ( $objFile, "<td>"&$strIESetting2.AutoProxyDetectMode&"</td>"&@CRLF ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Proxy override excludes:</td>"&@CRLF ) FileWrite ( $objFile, "<td>"&$strIESetting2.ProxyOverride&"</td>"&@CRLF ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Proxy override settings:</td>"&@CRLF&"<td>" ) $PS2 = StringSplit( $strIESetting2.ProxyServer, ";") _ArrayDelete ( $PS2, 0 ) For $settinG1 in $PS2 FileWrite ( $objFile, $settinG1&"<BR>"&@CRLF) Next FileWrite ( $objFile, "</td></tr>" ) Next FileClose ( $objFile )I have a piece of code that works OK in VB but is not working in AutoIT and I was wondering if you could give me a hand. Below is a functional code snippet from the larger script that includes the problem code. Perhaps someone that is better at WMI than me can see where the issue is.$report = "c:\test.txt" $strComputer = "." $objFile = FileOpen ($report, 2) $objWMIService2 = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\"&$strComputer&"\root\CIMV2\Applications\MicrosoftIE") $colIESettings2 = $objWMIService2.ExecQuery ("Select * from MicrosoftIE_ConnectionSettings") For $strIESetting in $colIESettings2 FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Autoconfiguration URL:</td>"&@CRLF ) FileWrite ( $objFile, "<td>"&$strIESetting.AutoConfigURL&"</td>"&@CRLF ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) FileWrite ( $objFile, "<tr>"&@CRLF&"<td>Proxy Server:</td>"&@CRLF ) FileWrite ( $objFile, "<td>" ) $PS = StringSplit($strIESetting.ProxyServer, ";") For $settinG in $PS FileWrite ( $objFile, $settinG&"<br>"&@CRLF ) Next FileWrite ( $objFile, "<\td>" ) FileWrite ( $objFile, "<td>   </td></tr>"&@CRLF ) Next FileClose ( $objFile ) The output of the code is in html, so if you get it working the output will be the middle of a table that is defined earlier in my script.Thanks - Tom Anyone have a TRS 80 Model III for sale? 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