Jump to content
Sign in to follow this  
brian75

Use wild card with _FileWriteToLine

Recommended Posts

brian75

Greetings all,

I need to edit a user specific .xml file.  The file name will never be the same.  Is it possible to use a wild card for the file name with _FileWriteToLine?  That one .xml is the only file in that directory.  I was thinking something like this (Obviously, I tried this and it doesn't work):

#include <File.au3>
#RequireAdmin
_FileWriteToLine("C:\ProgramData\Microsoft\WwanSvc\Profiles\*.xml", 9, "<ConnectionMode>manual</ConnectionMode>", 1)

If not, I need to parse the file name and read it in to the _FileWriteToLine statement.  Can I get some hints as to how to do that?

Of course, I'm not married to using _FileWriteToLine.  If there's a better way to go about it I'm all for it.  I appreciate any help!

 

Share this post


Link to post
Share on other sites
jdelaney

what is the parent node you want it nested under?  You can use the XML dom to do so.

example:

$sXML = '<?xml version="1.0"?>' & @CRLF & '<Something/>'


$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadXML($sXML)
$oNode = $oXML.createElement("ConnectionMode")
$oNode.text = "manual"

$oParent = $oXML.selectSingleNode( '//Something' )
$oParent.appendChild($oNode)

ConsoleWrite($oXML.xml & @CRLF)

$oXML.save("yourfile.xml")

well, this is how to correctly modify the file.  what do you want from the wild card?  Are there multiple files?

Use _FileListToArray to get your collection, loop through that array, and do the above.

Edited 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.

Share this post


Link to post
Share on other sites
brian75

Hi jdelaney,

Thanks for your response!  I am not at all familiar with using the XML DOM so I am researching that now but it looks like what I need.  I'll post back my solution once I get it figured out or if I run into a roadblock.  Thanks again!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.