Thursday 25 December 2014

writing file using vbscript

'Option Explicit
dim objXML2,fso,strdir,CurrentDirectory,ExportFile,LocalPath,SVNPath,colNodes,objnode
Set objXML2 = CreateObject("Microsoft.XMLDOM")
objXML2.async = "false"
strdir=WScript.Arguments.item(0)'PRODUCTINFO.xml

set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.GetAbsolutePathName(".")
Set ExportFile = fso.CreateTextFile(CurrentDirectory&"\SVNExport.cmd", True)
ExportFile.WriteLine("@echo off")
'ExportFile.WriteLine("start /b 1")

LocalPath = 'WScript.Arguments.item(1)
SVNPath = 'WScript.Arguments.item(2)

'ExportFile.WriteLine("LocalPath: " & LocalPath)
'ExportFile.WriteLine("SVNPath: " & SVNPath)

If (Not objXML2.load(strdir)) Then
    wscript.echo "Unable to load file '" & strdir & "'. "
    WScript.Quit(1)
End If

Set colNodes = objXML2.selectNodes ("/PRODUCTINFO/PRODUCT")
For Each objNode in colNodes
    wscript.echo objnode.getAttribute("NAME")& " : " & objnode.getAttribute("VERSION")
ExportFile.WriteLine("echo Getting " & objnode.getAttribute("NAME") & " of version " & objnode.getAttribute("VERSION") & " from SVN")
ExportFile.WriteLine("""C:\Program Files\TortoiseSVN\bin\svn.exe"" export """ & SVNPath & "/" & objnode.getAttribute("NAME") & "/" & objnode.getAttribute("VERSION") & """   """ & LocalPath & "\" & objnode.getAttribute("NAME") & "\" & objnode.getAttribute("VERSION"))
Next
ExportFile.WriteLine("echo Export Completed")
ExportFile.close()