coles Posted February 23, 2016 Share Posted February 23, 2016 Hi guys I am new to Autoit. I would like to Automate a task which i do at the moment i am running a batch file which creates a1.txt,a.txt as shown below netsh mbn show interface dump > c:\temp\a.txt C:\Users\admin>ipconfig /all > c:\temp\a1.txt and then i have to open the cmd prompt to merge both files with the command below Open command prompt in folder c:\temp for %f in (*.txt) do type "%f" >> Audit.txt which merges both text files into 1,which is working perfectly(minus the time waste remote logging into every system to combine the file). Can someone help out to make the whole thing automated. Gathering details from netsh and ipconfig then merging the result Thanks for the comments Link to comment Share on other sites More sharing options...
spudw2k Posted February 24, 2016 Share Posted February 24, 2016 (edited) If you change the redirector for your ipconfig command to >> it will append the results to the text file.netsh mbn show interface dump > c:\temp\a.txtipconfig /all >> c:\temp\a1.txt This page may have some useful information for you regarding command line execution and output redirection. Edited February 24, 2016 by spudw2k coles 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
coles Posted February 24, 2016 Author Share Posted February 24, 2016 @spudw2k Awesome thanks for that, i will try merging the files with a snippet. Link to comment Share on other sites More sharing options...
coles Posted February 24, 2016 Author Share Posted February 24, 2016 @spudw2k i Ended up using netsh mbn show interface dump >> c:\temp\a.txt & ipconfig /all >> c:\temp\a.txt so that it puts both results to 1 file. Link to comment Share on other sites More sharing options...
spudw2k Posted February 24, 2016 Share Posted February 24, 2016 (edited) be careful. >> causes output to append to a file. > overwrites the contents of a file. If you only use >> your file will grow, and grow, and grow. You should still use > for the netsh dump and >> for ipconfig to create a "fresh" file each run. Edited February 24, 2016 by spudw2k coles 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
coles Posted February 24, 2016 Author Share Posted February 24, 2016 7 hours ago, spudw2k said: be careful. >> causes output to append to a file. > overwrites the contents of a file. If you only use >> your file will grow, and grow, and grow. You should still use > for the netsh dump and >> for ipconfig to create a "fresh" file each run. @spudw2k Thanks for the guidance, i have changed the batch file into Auto it as below Example1() Func Example1() RunWait(@ComSpec & " /c " & "netsh.exe mbn show interface dump > c:\temp\a.txt"); RunWait(@ComSpec & " /c " & "ipconfig /all >> c:\temp\a.txt"); EndFunc is this rite way to put it in autoit or it needs more conditioning? Link to comment Share on other sites More sharing options...
spudw2k Posted February 29, 2016 Share Posted February 29, 2016 Looks fine to me. coles 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
coles Posted March 7, 2016 Author Share Posted March 7, 2016 Thanks @spudw2k Link to comment Share on other sites More sharing options...
coles Posted March 18, 2016 Author Share Posted March 18, 2016 @spudw2k can you please help me with one more query i have a.txt file with (only) content <vehicle>100</vehicle>, is it possible to remove <vehicle></vehicle> and just keep the 100 . Link to comment Share on other sites More sharing options...
alien4u Posted March 18, 2016 Share Posted March 18, 2016 Yes cole there is multiple ways of doing this. Example Code: #include <MsgBoxConstants.au3> #include <Array.au3> #include <String.au3> ; This give you the file handle and open the file to read $fileid = FileOpen("a.txt") ; This read the first line of the file and store it on $fileline variable. $fileline = FileReadLine($fileid, 1) ; Return an Array with your value in the first position. $value = _StringBetween($fileline,">","<") ; Get that value from the first position. $finalvalue = $value[0] MsgBox("","","The value inside a.txt and between <vehicle> and </vehicle> is: "&$finalvalue) You can do this in another way using StringLeft or StringRight and then you dont need to use an array. About your merge file thing, if you do that at certain Time you could code something that check the date and time and make that for you and send you an email with the resulting file and you don't need to Log In or do anything on the remote computer. Important Note: Before you ask simple questions make sure you search on the Help file, is everything there. People here answering your questions are doing this like volunteers so don't expect this people code for you. Happy Coding. Kind Regards Alien Link to comment Share on other sites More sharing options...
MaxPlankpar Posted March 23, 2016 Share Posted March 23, 2016 (edited) Edited April 1, 2016 by MaxPlankpar Link to comment Share on other sites More sharing options...
spudw2k Posted March 23, 2016 Share Posted March 23, 2016 3 hours ago, MaxPlankpar said: "Merge my files" crams files together nicely. A bit erroneous for concatenating text files though, wouldn't you agree? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
coles Posted March 28, 2016 Author Share Posted March 28, 2016 Thanks @alien4u @MaxPlankpar @spudw2k for replying for my query. I ended up using Autoit instead of a Batch file. 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