Click here to Skip to main content
Click here to Skip to main content
Go to top

Delete obsolete SMS clients

, 13 Jan 2007
Rate this:
Please Sign up or sign in to vote.
An easy way to delete all the obsolete SMS clients...

Sample Image - DeleteObsoleteSMSClients.jpg

Introduction

Deleting the obsolete SMS clients can really be a pain in the ass. Especially at environments where a few 100 SMS clients get obsolete every day.

Using the code

  • Start up the application.
  • Issue the computername of the SMS server and the SMS Site Code.
  • Click on query to search for obsolete SMS clients.
  • Click on delete to delete the found obsolete SMS clients.

    I used the System.Management to query for and delete the obsolete SMS clients.

    Query for obsolete SMS clients:
    private void ThreadQueryObsolete()
    {
        ...       
    
        ManagementClass systemclass = new ManagementClass("SMS_R_System");
        ManagementScope oMs = new ManagementScope("\\\\" + tbxSMSServername.Text.Trim() + "\\root\\SMS\\Site_" + tbxSMSSiteCode.Text.Trim());
        systemclass.Scope = oMs;
    
        ObjectQuery oQuery = new ObjectQuery("SELECT ResourceId, NetbiosName FROM SMS_R_System WHERE Obsolete = 1");
    
        ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
        ManagementObjectCollection oReturnCollection = oSearcher.Get();
    
        foreach (ManagementObject oReturn in oReturnCollection)
        {
            string[] obsoletes = new string[2];
            obsoletes[0] = oReturn["ResourceId"].ToString();
            obsoletes[1] = oReturn["NetbiosName"].ToString();
            obsoleteList.Add(obsoletes);
            
            ListViewItem item = new ListViewItem(oReturn["NetbiosName"].ToString(), 0);
            SetListViewItems(item);
        }
    
        ...
    }
    
    Delete the obsolete SMS clients:
    private void ThreadDeleteObsolete()
    {
        ...       
    
        ManagementClass systemclass = new ManagementClass("SMS_R_System");
        ManagementScope oMs = new ManagementScope("\\\\" + tbxSMSServername.Text.Trim() + "\\root\\SMS\\Site_" + tbxSMSSiteCode.Text.Trim());
        systemclass.Scope = oMs;
        ManagementObject system = systemclass.CreateInstance();
    
        ObjectQuery oQuery = new ObjectQuery("SELECT ResourceId, NetbiosName FROM SMS_R_System WHERE ResourceId = '" + ((string[])obsoleteList[i])[0] + "' AND NetbiosName = '" + ((string[])obsoleteList[i])[1] + "' AND Obsolete = 1");
    
        ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
        ManagementObjectCollection oReturnCollection = oSearcher.Get();
    
        foreach (ManagementObject oReturn in oReturnCollection)
        {
            system["ResourceId"] = oReturn["ResourceId"].ToString();
            system.Delete();
        }
    
        ...
    }
    

    History

    Version 1.0 - Initial version.

  • License

    This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

    Share

    About the Author

    ESTAN
    Software Developer
    Spain Spain
    Hi,
     
    I am 31 years old, coming from Aarschot, Belgium and I studied Master in Electronics and Informatics.
     
    I learned to program while I was working for an International company, making tools outside the hours so I could do my daily tasks more quickly and easily.
     
    After I while I got appreciated what gave me opportunities to be a full time programmer.
    Since 2 years I am full time developing in C#, VB.NET, VBScript and ASP.NET.
     
    In July 2007 I quit my job and changed my live completely... well almost. I moved to Playa San Juan, Alicante, Spain and found work as .NET consultant in a BI company.
     
    Since November 2008 I moved to the centre of Alicante to be more closer to my work.

    Comments and Discussions

     
    QuestionDeleting SMS log files ? PinmemberSoftware_Specialist22-May-07 22:40 
    AnswerRe: Deleting SMS log files ? PinmemberESTANNY6-Oct-07 6:56 
    QuestionHow about deleting sms log files ? PinmemberSoftware_Specialist22-May-07 22:39 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web04 | 2.8.140926.1 | Last Updated 13 Jan 2007
    Article Copyright 2007 by ESTAN
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid