Click here to Skip to main content
15,886,518 members
Articles / Operating Systems / Windows
Article

Delete obsolete SMS clients

Rate me:
Please Sign up or sign in to vote.
3.20/5 (3 votes)
13 Jan 2007GPL3 24.8K   428   7   4
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:
    C#
    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:
    C#
    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)


    Written By
    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 ? Pin
    Software_Specialist22-May-07 22:40
    Software_Specialist22-May-07 22:40 
    AnswerRe: Deleting SMS log files ? Pin
    ESTAN6-Oct-07 6:56
    ESTAN6-Oct-07 6:56 
    Hello,

    I just saw your post, are you still in the need of deleting the obsolete log files all over the SMS clients?

    Just mail me or reply on this msg, maybe i can help you out.
    QuestionHow about deleting sms log files ? Pin
    Software_Specialist22-May-07 22:39
    Software_Specialist22-May-07 22:39 

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

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