ledigeine Posted November 16, 2012 Share Posted November 16, 2012 I have been writing this UI script for some people at work, just makes their job easier and i get to learn how to think of things from a Dev POV. Jokingly somebody complained they don't like having to copy my exe and xml file each time i update them. So with that i thought it could be cool to make an 'install' that just unpacks the exe and xml.(i found FileInstall, im assuming thats what id use.) The only issue i have is, there are settings held in the XML. So one user could like their screen setup this way while another has it setup differently. The XML will hold that info, but my new XML would clear it. 1. Would FileInstall be what it sounds like i need? 2. Any ideas on how to move all other info into their current xml or maybe set some nodes to be persistant or something like that and not get updated? Link to comment Share on other sites More sharing options...
BrewManNH Posted November 16, 2012 Share Posted November 16, 2012 If you use just FileInstall you're going to have 3 options, create a new file if it doesn't exist, overwrite the file if it exists, or don't overwrite the file if it exists. With that in mind, it's not going to do what you'd need it to do if you don't want to lose custom settings. You could use it to put the file in place if it doesn't exist with the no overwrite flag, but if the new xml file has different settings in it than the old one, the new program won't have access to those settings unless you recreate them when you run your program. ledigeine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdelaney Posted November 16, 2012 Share Posted November 16, 2012 (edited) I'd suggest using microsoft.XMLDOM...you can search for if a node is not present (in the old file), and add if needed:http://www.w3schools.com/dom/default.aspIt's all up to you, to set the logic to override a node...such as, you can make an attribute, and set it True/False if you want that node to override/not override.For the EXE route, i have a share, where I store all my scripts. When executed, I check that the EXE is running from a temp file (known), and if not, then I copy from the share to that Temp file, then have the script call the temp file...that way, you always run the current. (as long as you don't run from the temp file manually ) Edited November 16, 2012 by jdelaney ledigeine 1 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...
water Posted November 16, 2012 Share Posted November 16, 2012 There is an XML UDF available. Have a look at the Example Scripts section. 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 Link to comment Share on other sites More sharing options...
ledigeine Posted November 16, 2012 Author Share Posted November 16, 2012 Ok so looking at what was said, FileInstall will work for the EXE. But the xml will be SOL. I should use an xml dom, which i think i am.... because i already pull data from the xml in the script. So as opposed to haveing a installsheild type thing like im used to with other programs. (really for two files thats excessive) I could just make a script that copies my exe and overwrites the old one, then updates the xml with the new nodes. So the 'user setting' type nodes dont go byebye. Does it sound like I know what im talking about? Link to comment Share on other sites More sharing options...
jdelaney Posted November 16, 2012 Share Posted November 16, 2012 something like this, at the top of you EXE would do it: Global $gsFILE_TempDir = "C:AutomationTemp" ; change to what you want the file to be Global $gsFILE_ScriptName = @ScriptName If Not StringInStr(@ScriptDir, $gsFILE_TempDir ) Then FileCopy ( "full path to exe on share with exe included", $gsFILE_TempDir, 9 ) Run ( $gsFILE_TempDir & $gsFILE_ScriptName ) Exit EndIf ledigeine 1 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...
ledigeine Posted November 16, 2012 Author Share Posted November 16, 2012 Looks good thank you, i will send you all flowers one day. Link to comment Share on other sites More sharing options...
jdelaney Posted November 16, 2012 Share Posted November 16, 2012 (edited) Then, you might want to get tricky, and kill all open processes of the exe, except for the current...that will ensure that the copy can occur...then you have to add logic to verify the share is mapped, or prompt user with a login, or hardcode a map if ok with your company security. Using ProcessList with the @scriptname should do it, then skip the pid where = @AutoItPID (only if running as compiled exe) Edited November 16, 2012 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 Sorry to bring this up again but im having issues. As i thought about this a little more I will need to store a version number in the exe i have to check with the XML to make sure they play well together. (say i have a new exe that doesnt understand the xml structure and it errors.) So in the exe i have a version set, when opening the script it will check the version in the exe compared to the one stored in xml. If it doesnt match it will show a msg box and all that. I just took a little class on xml months ago and i have no idea if im structuring things correctly. When i try to pull the version from the xml for the compare it never works for me. I have pulled info from this xml many times for other things but its just not working now and i have no idea why. The only thing i can think of is that the version node will just have one item, so it wont be an array when its returned. That shouldnt be an issue tho. Im using the _xmldomwrapper from this forum, the xml looks like this. <root> <vers>2.5.2</vers> otherjunk down here </root> So when i run the script it compares the exe version and the xml version, I get $xmlvers returning a -1. $xmlvers = _XMLGetValue("/root/vers") I need xmlvers to return the version kept in the xml. Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 not sure about the udfs $string = '<root><vers>2.5.2</vers></root>' $oXML=ObjCreate("Microsoft.XMLDOM") $oXML.loadxml($string) ; load document $oVersion= $oXML.selectSingleNode("//root/vers") ConsoleWrite ( $oVersion.text & @CRLF ) 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 Sorry dumb question, but when i do that $oxml.loadxml its having an issue there. SHould i be including something? That kinda looks like vb, i think... right? Again sorry im a noob with all this. Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 (edited) If you are loading a file, use .load instead.xml dom: http://www.w3schools.com/dom/default.asp Edited November 26, 2012 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 Ok i get that but when doing .load in autoit it doesnt understand it. It wants an = after the variable. I dont think that site will help me understand how to make autoit understand what im doing. Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 (edited) $string = 'C:yourdiryourfile.xml' $oXML=ObjCreate("Microsoft.XMLDOM") $oXML.load($string) ; load file $oVersion= $oXML.selectSingleNode("//root/vers") ConsoleWrite ( $oVersion.text & @CRLF ) Edited November 26, 2012 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 (edited) Ok i got a little farther now, the only problem now is that the version is not showing a string. I am trying to make it display in a msgbox so the user will know if they need a new exe or a new xml file. I was missing that obj create part, i guess that makes the variable be able to do different things. EDIT: Why am i using a udf's when you can just hit the xml with these items already in autoit? Edited November 26, 2012 by ledigeine Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 (edited) you can't use the methods of an object without declaring the object. run this, and tell me if there is any output...if not, then your XML is not a valid XML structure, which you will need to fix. $string = 'C:yourdiryourfile.xml' $oXML=ObjCreate("Microsoft.XMLDOM") $oXML.load($string) ; load file ConsoleWrite ( $oXML.xml & @CRLF ) edit: the UDF's probably do use these methods, i just never cared to look at them, since i am familiar with the objects Edited November 26, 2012 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 yeah just pretty much shows my whole xml in the bottom section. I think it is valid... now is it setup in a clean or proper way? I doubt it. Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 try this: $string = 'C:yourdiryourfile.xml' $oXML=ObjCreate("Microsoft.XMLDOM") $oXML.load($string) ; load file $oVersion= $oXML.selectSingleNode("//vers") ConsoleWrite ( $oVersion.text & @CRLF ) else, i'm out of ideas for you...is it possible you have multiple nodes = 'vers'? ledigeine 1 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...
ledigeine Posted November 26, 2012 Author Share Posted November 26, 2012 Ok that seemed to work, I have to look into when i can use these methods like .text and all that. I think it would help me out a bunch when things do not seem to want to display. Link to comment Share on other sites More sharing options...
jdelaney Posted November 26, 2012 Share Posted November 26, 2012 you understand what a 'root' is, right? I think you should catch up on your XML/XPATHS...the root is the highest node, and not necessarily 'root' 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...
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