Get a list of CSS Projects
C# Code:
CReplicationServer cssSvr = new CReplicationServerClass();cssSvr.Initialize(Environment.MachineName);object dummy = new object();dummy = 0;while ((int)dummy != -1){ CReplicationProject obj = (CReplicationProject)cssSvr.EnumProjects(ref dummy); Console.WriteLine(obj.get_Name().ToString());} |
VBScript Code:
Option Explicit On Error Resume Nextconst CSS_ERROR_NO_PROJECTS = 15100const CSS_ERROR_NO_MORE_ITEMS = -2147422485dim ReplServerset ReplServer = CreateObject("CssApi.ReplicationServer")ReplServer.Initialize("")dim Projectdim Iteratordim ReplProjectIterator = 0Wscript.Echo "The projects are:"do while True'Clear any error textErr.Clear'Get the next projectset ReplProject = ReplServer.EnumProjects(Iterator)'Display error message and'Quit if empty object returned (no more instances)if IsEmpty(ReplProject) thenWscript.Echo "Empty project object returned."exit doend if'Display error message and'Quit if "No projects defined" error dim ReplErrorReplError = Err.Numberif ReplError = CSS_ERROR_NO_PROJECTS thenWscript.Echo "No projects defined."exit doelseif (ReplError = CSS_ERROR_NO_MORE_ITEMS) then'Quit if "No more items" error (we've reached the end of the list)exit doelseif Err.Number <> 0 then'Display error message and quitWscript.Echo "Error Description: " & Err.Descriptionexit doend ifWscript.Echo ReplProject.NameLoop |
Comments
- Anonymous
May 31, 2009
PingBack from http://indoorgrillsrecipes.info/story.php?id=3275