Jump to content
Sign in to follow this  

Uninstall Software

Recommended Posts


I'm looking at throwing together a tidy little package to remove SMS, Rename a Workstation then reinstall SMS.

All of this to be done remotely.

I'm currently running this whole process through two VBScripts and the SMS GUI - CCRgen.

I can replicate the VBScript for Renaming the Workstation, but stuck on replicating the script for removing SMS.

Basically I plan on my AutoIT script to wait until SMS has been removed, then kickoff the rename, then kickoff SMS reinstall before going to next machine.

Plan to set it up to run off of a supplied list of machines (old names - new names) or have the ability to supply the old/new names manually.

Any assistance/pointers would be greatly appreciated.

VBScript for removing SMS.

strComputer = InputBox("Enter Machine Name")
strApplicationName = "SMS Advanced Client"

Set wshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select * From Win32_Product where Name = '" & strApplicationName & "'")

    For Each objSoftware in colSoftware

        If objSoftware.Name = strApplicationName Then
            ApplicationFound = True
            MsgBox "Removing The " & strApplicationName & " From " & UCase(strComputer)


            MsgBox "Done"

        End If

Set colSoftware = NOTHING
Set objWMIService = NOTHING
Set wshShell = NOTHING

If ApplicationFound <> True Then MsgBox strApplicationName & " Is Not Installed On "  & UCase(strComputer)

Script for Renaming Workstation.

SET oShell = CREATEOBJECT("Wscript.Shell")

oShell.CurrentDirectory = "W:\ScriptTools"

sAccount = INPUTBOX("Which Account to use?", "Account Name", "")
sPass = INPUTBOX("Supply password for account:","PASSWORD","")
sOldComputer = INPUTBOX("OLD Machine Name","OLD","")
sNewComputer = INPUTBOX("NEW Machine Name:","NEW","")

Return = oShell.Run("netdom renamecomputer " & sOldComputer & " /NewName:" & sNewComputer & " /UserD:" & sAccount & " /PasswordD:" & sPass & " /Force",1,TRUE)

If Return = 0 Then
    MsgBox "Success!" & VBCR & Return
    MsgBox "FAILURE!!" & VBCR & Return
End If


Adding SMS to new Machine.

Using SMS tool - CCRgen

Edited by Country73

If you try to fail and succeed which have you done?AutoIt Forum Search

Share this post

Link to post
Share on other sites

vbscript can be replicated within AutoIt using ObjCreate methods... but you could also enumerate through HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\... , DisplayNames to find "SMS Advanced Client" and run it's UninstallString

But it seems more intuitive to your experience to just convert it to AutoIt's ObjCreate syntax.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post

Link to post
Share on other sites

Believe that's what I was looking for.

Used to script with VBScript all the time, but the AutoIT bug has got a firm hold on me now!

Trying to do as mush scripting through straight AutoIT, and revamping my old scripts into AutoIT.

Thanks for the point in the right direction.

Hopefully I can stumble my way through this and add to my personal knowledge base!

If you try to fail and succeed which have you done?AutoIt Forum Search

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this