Prodigus Posted June 3, 2006 Posted June 3, 2006 This is probably an easy thing for you pros but I'm just getting started at this (and can't stop)... I'm trying to grab some information using logparser (a computers IP address) and I want the result of the Query (the IP address) to be $var2 (my variable name that I'm going to use. $sCmd2Run2 = "logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off" $sErrorStatus = RunWait($sCmd2Run2, @ScriptDir, @SW_HIDE) if I run this it will return a IP address, I merely want that IP address to be automatically recognized as $var2 I don't want to have to place it in a txt file first and then read it out of there since I will be doing about 4000 of these and I would think all that opening and closing of the file would take away from my performance. Any ideas? Thanks!!
4gotn1 Posted June 3, 2006 Posted June 3, 2006 what is the purpose of your software?..... it would be easiest to just show us some (full) source code
Prodigus Posted June 3, 2006 Author Posted June 3, 2006 what is the purpose of your software?..... it would be easiest to just show us some (full) source code lolThe end result of the script I'm working on is not very exciting actually it will merely move computers around within Active Directory to different OU's based on their IP address and the "imagetype" registry key that our techs added to the administrative and clinical images of all machines in the enterprise. The image type will tell me which top level OU it belongs to and then the IP address will tell me the geographical location of the machine. From that information I can keep machines in their proper OU's and thus they get their proper GPO's applied for that location and type. So even if someone moves a machine, I'll know....But right now I'd just like to figure out how to take the results of a query and have it automatically recognized as a variable versus having to do that many reads and writes from another txt file.....Thanks!!
JMiller Posted June 3, 2006 Posted June 3, 2006 (edited) This is probably an easy thing for you pros but I'm just getting started at this (and can't stop)...I'm trying to grab some information using logparser (a computers IP address) and I want the result of the Query (the IP address) to be $var2 (my variable name that I'm going to use.$sCmd2Run2 = "logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off" $sErrorStatus = RunWait($sCmd2Run2, @ScriptDir, @SW_HIDE)if I run this it will return a IP address, I merely want that IP address to be automatically recognized as $var2I don't want to have to place it in a txt file first and then read it out of there since I will be doing about 4000 of these and I would think all that opening and closing of the file would take away from my performance.Any ideas?Thanks!!I'm not sure what you mean. Where is the IP address returned? From the command output? I don't know if this can be done with autoit, but you might consider vbscript wshshell.exec method (http://www.ss64.com/wsh/exec.html). Of course some of the resident autoit experts probably have a way to do it with autoit. Edited June 4, 2006 by JMiller
Prodigus Posted June 4, 2006 Author Posted June 4, 2006 Yes, when you run this command with logparser it will return the IP address of the machine (as long as a) the machine is on and the IP was issued through DHCP. "logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off" That machine name is actually replaced by a variable in the actual script
JMiller Posted June 4, 2006 Posted June 4, 2006 (edited) Yes, when you run this command with logparser it will return the IP address of the machine (as long as a) the machine is on and the IP was issued through DHCP."logparser ""SELECT Value FROM ""\\23T7111\HKLM\SYSTEM\CurrentControlSet\Services\TCPIP"" WHERE ValueName = 'DhcpIPAddress'"" -i:REG -headers:off"That machine name is actually replaced by a variable in the actual scriptHmm I think I might have found a function in autoit that works.. see nfwu's post below.ScriptI noticed he is using a command called StdoutRead() to get the command output. Edited June 4, 2006 by JMiller
JMiller Posted June 4, 2006 Posted June 4, 2006 I'll check it out.. Thanks!! No prob btw I checked the help files in autoit and you have to pass the 4th parameter (2 for stdout) to the Run command to capture the output. It shows that in the above script, but it's easy to miss.
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