gniuz Posted December 10, 2009 Posted December 10, 2009 (edited) Hi, I'm new to AutoIt and have been focussing on Powershell instead. However, there's a need to accomplish something that I (even with the help of the WASP PSSnapin) can't get to work. Can anyone please provide me an autoit translation of the following powershell script? It basically just reads a csv and splits it per line. I've found some references on this forum but they don't seem to read and split the stuff per line. Many thanks! Input.csv: ---------- username, oldpw, newpw jimbo, seed, homebrew treehugginghippie, green, leaf terminatorx, bass, howlowcanyougo powershell.ps1: --------------- $csv_file = $env:systemdrive+'\input.csv' $csv_info = Import-Csv $csv_file foreach ($line in $csv_info) { & bla.exe -username $($line.username) -oldpw $($line.oldpw) -newpw $($line.newpw) } Edited December 10, 2009 by gniuz
Baraoic Posted December 10, 2009 Posted December 10, 2009 (edited) I don't know powershell but if you wanna read a multilined file and split it per line you could do _FileReadToArray. It would read that text document and put each line into a cell in the array then you could do whatever you wanted with it from there. Edited December 10, 2009 by Onichan
water Posted December 10, 2009 Posted December 10, 2009 Something like: #include <file.au3> _FileReadToArray("filename",$aArray) For $iCount = 1 To $aArray[0] $aFields = StringSplit($aArray[$iCount],",") ShellExecuteWait("bla.exe","-username " & $aFields[1] & " -oldpw " & $aFields[2] & " -newpw " & $aFields[3]) Next My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
gniuz Posted December 10, 2009 Author Posted December 10, 2009 Something like: #include <file.au3> _FileReadToArray("filename",$aArray) For $iCount = 1 To $aArray[0] $aFields = StringSplit($aArray[$iCount],",") ShellExecuteWait("bla.exe","-username " & $aFields[1] & " -oldpw " & $aFields[2] & " -newpw " & $aFields[3]) Next Wow guys, thanks for the extremely quick reply. I'll start experimenting right away and let you know. Tnx!
gniuz Posted December 10, 2009 Author Posted December 10, 2009 That went great.. Now here's something else. What if the CSV file would be an XML file. How would this change the script? input.xml: ---------- <UserList> <User> <Name>jimbo</Name> <OldPW>seed</OldPW> <NewPW>homebrew</NewPW> </User> <User> <Name>treehugginghippie</Name> <OldPW>green</OldPW> <NewPW>leaf</NewPW> </User> <User> <Name>terminatorx</Name> <OldPW>bass</OldPW> <NewPW>howlowcanyougo</NewPW> </User> </UserList> Once again, thanks for your time!
water Posted December 10, 2009 Posted December 10, 2009 Maybe this can help with XML: XML DOM Wrapper My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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