Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy username into xml file

Status
Not open for further replies.

JPL910

MIS
Oct 16, 2008
24
US
I am trying to create an xml file on the local drive of the user computer. The file must contain the logged on users name inside it. Here is what I have:

Set objNetwork = wscript.CreateObject("wscript.network")
Set doc = CreateObject("Microsoft.XMLDOM")
MsgBox objNetwork.Username

doc.async = false
doc.ValidateonParse = False
doc.resolveExternals = False

doc.LoadXml("<?xml version='1.0'?><DataRoot><UserName>TestUsr<UserName></UserName></UserName></DataRoot>")
doc.save "C:\test.xml"
set doc = Nothing

Where I have TestUsr, I need it to self poplulate with the logged on users name.

Thanks for the help!!
 
TestUsr = objNetwork.Username
doc.LoadXml("<?xml version='1.0'?><DataRoot><UserName>" & TestUsr & "<UserName></UserName></UserName></DataRoot>")

-Geates
 

I was able to get it working this way:

doc.LoadXml("<?xml version='1.0'?><DataRoot><UserName><UserName>"&objNetwork.Username&"</UserName></UserName></DataRoot>")


Thank you for your response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top