Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Remove XP Windows Messenger

Keywords:     Remove XP Windows Messenger

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Script name:  RmwinMsg.wbt
;;
;;  Purpose:    Uninstalls  Windows Messenger from a computer running 
;;              Windows XP
::
;; Parameter:  param1 - Can be anything but presences means Quiet mode.
;;                      Quite mode turns off error messages and the 
;;                      conformation prompt.  Is does not turn off
;;                      all  Sysocmgr.exe errors, however.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Copyright 2001 Wilson WindowWare, Inc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  Function name: DisplayMessage
;;
;;  Purpose: Displays a message if script is not in quiet mode.
;;
;;  Return: Always 1 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#DefineFunction DisplayMessage(bQuiet, sMessage)

   if ( !bQuiet )
      message("Remove Windows Messenger", sMessage)

   Return 1
#EndFunction 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Script body
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Need the Network extender to perform admin group membership check.
AddExtender("WWWNT34i.DLL")

; Parameter can be anything but indicates that messages should be displayed.
if  param0 > 1  then exit
if  param0 == 1 then bQuiet = @True
else bQuiet = @False

; Make sure we are running on XP (5.1)
if (WinVersion(1) != 5)  || (WinVersion(0) < 1)
   DisplayMessage(bQuiet, "Wrong version of windows.  Please run on Windows XP.")
   exit
endif

; User must be an administrator
sUserName = wntUserInfo(0)
if !wntMemberGet("", "Administrators", sUserName, @LOCALGROUP)
   DisplayMessage(bQuiet, "Window messanger removal failed: You must be an administrator to use this program. ")
   exit
endif

; Prompt user if not in quiet mode.
if !bQuiet 
   YesNo = AskYesNo("Remove Windows Messenger?", "This script will remove Windows Messanger.%@CRLF% Yes = continue%@CRLF% No = quit")
   If YesNo != @YES Then Exit
endif

; System path information.
sSystem32 = DirWindows(1)
sWindir   = DirWindows(0)
sSysocmgr = "%sSystem32%SYSOCMGR.EXE"

; Create answer file.
LastError()
nErrorMode = Errormode(@Off)
sAnswerFile = FileCreateTemp ("rmw")
hAnswer      = FileOpen(sAnswerFile, "WRITE")
if hAnswer == 0
   DisplayMessage(bQuiet, "Window messanger removal failed: Unable to open temporary file. ")
   exit
endif

; Write the answer file
FileWrite(hAnswer, "[Components]")
FileWrite(hAnswer, "msmsgs = off") 

FileClose(hAnswer)

; Check for write errors file errors
if LastError()
   DisplayMessage(bQuiet, "Window messanger removal failed: Unable to create temporary file. ")

   ; Cleanup
   if FileExist(sAnswerFile) then FileDelete(sAnswerFile)
   exit
endif

; Turn error handling back on.
ErrorMode(nErrorMode)

; Construct the name of the optional components inf file and make sure it exists.
sInfFile = "%sWindir%\inf\sysoc.inf"
if !FileExist(sInfFile)
   DisplayMessage(bQuiet, "Window messanger removal failed: Unable find a system file.")
   exit
endif

; Sysocmgr file path and name.
; sSysocmgr - path and name of system component manager.
; /i:       - location and name of inf file
; /q        - quiet mode
; /u:       - answer file
bResult = RunShell(sSysocmgr, "/i:%sInfFile% /q /u:%sAnswerFile%", "", @HIDDEN, @WAIT) 
if !bResult  then sMessage = "Window messanger removal failed: Unable find a system file."
else sMessage = "Window messanger removed."

; Inform use of result if not in quiet mode.
DisplayMessage(bQuiet, sMessage)

; Cleanup
if FileExist(sAnswerFile) then FileDelete(sAnswerFile)

exit ; done



Article ID:   W15286