ÿþ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 '   N a m e :   O f f S c r u b C 2 R . v b s  
 '   A u t h o r :   M i c r o s o f t   C u s t o m e r   S u p p o r t   S e r v i c e s  
 '   C o p y r i g h t   ( c )   2 0 1 4   -   2 0 1 5   M i c r o s o f t   C o r p o r a t i o n  
 '   S c r i p t   t o   r e m o v e   O f f i c e   C l i c k   T o   R u n   ( C 2 R )   p r o d u c t s  
 '   w h e n   a   r e g u l a r   u n i n s t a l l   i s   n o   l o n g e r   p o s s i b l e  
 '  
 '   S c o p e :   O f f i c e   2 0 1 3 ,   2 0 1 6   a n d   O 3 6 5   C 2 R   p r o d u c t s  
 ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
  
 O p t i o n   E x p l i c i t  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '  
 '       D e c l a r a t i o n   o f   c o n s t a n t s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
  
 C o n s t   S C R I P T V E R S I O N       =   " 2 . 0 0 "  
 C o n s t   S C R I P T F I L E             =   " O f f S c r u b C 2 R . v b s "  
 C o n s t   S C R I P T N A M E             =   " O f f S c r u b C 2 R "  
 C o n s t   R E T V A L F I L E             =   " S c r u b R e t V a l F i l e . t x t "  
 C o n s t   O N A M E                       =   " O f f i c e   C 2 R   /   O 3 6 5 "  
 C o n s t   H K C R                         =   & H 8 0 0 0 0 0 0 0  
 C o n s t   H K C U                         =   & H 8 0 0 0 0 0 0 1  
 C o n s t   H K L M                         =   & H 8 0 0 0 0 0 0 2  
 C o n s t   H K U                           =   & H 8 0 0 0 0 0 0 3  
 C o n s t   P R O D L E N                   =   1 3  
 C o n s t   S Q U I S H E D                 =   2 0  
 C o n s t   C O M P R E S S E D             =   3 2  
 C o n s t   R E G _ A R P                   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ U n i n s t a l l \ "  
 C o n s t   V B _ Y E S                     =   6  
 C o n s t   V B _ N O                       =   7  
  
 C o n s t   E R R O R _ S U C C E S S                                   =   0       ' B i t   # 1 .     0   i n d i c a t e s   S u c c e s s .   S c r i p t   c o m p l e t e d   s u c c e s s f u l l y  
 C o n s t   E R R O R _ F A I L                                         =   1       ' B i t   # 1 .     F a i l u r e   b i t .   I n d i c a t e s   a n   o v e r a l l   s c r i p t   f a i l u r e .  
                                                                                     ' R E S E R V E D   b i t !   R e t u r n e d   w h e n   p r o c e s s   i s   k i l l e d   f r o m   t a s k   m a n a g e r  
 C o n s t   E R R O R _ R E B O O T _ R E Q U I R E D                   =   2       ' B i t   # 2 .     R e b o o t   b i t .   I f   s e t   a   r e b o o t   i s   r e q u i r e d  
 C o n s t   E R R O R _ U S E R C A N C E L                             =   4       ' B i t   # 3 .     U s e r   C a n c e l   b i t .   C o n t r o l l e d   c a n c e l   f r o m   s c r i p t   U I  
 C o n s t   E R R O R _ S T A G E 1                                     =   8       ' B i t   # 4 .     I n f o r m a t i o n a l .   M s i e x e c   b a s e d   i n s t a l l   w a s   n o t   p o s s i b l e  
 C o n s t   E R R O R _ S T A G E 2                                     =   1 6     ' B i t   # 5 .     C r i t i c a l .   N o t   a l l   o f   t h e   i n t e n d e d   c l e a n u p   o p e r a t i o n s   c o u l d   b e   a p p l i e d  
 C o n s t   E R R O R _ I N C O M P L E T E                             =   3 2     ' B i t   # 6 .     P e n d i n g   f i l e   r e n a m e s   ( d e l   o n   r e b o o t )   -   O R   -   R e m o v a l   n e e d s   t o   r u n   a g a i n   a f t e r   a   s y s t e m   r e b o o t .  
 C o n s t   E R R O R _ D C A F _ F A I L U R E                         =   6 4     ' B i t   # 7 .     C r i t i c a l .   D a   c a p o   a l   f i n e   ( s e c o n d   a t t e m p t )   s t i l l   f a i l e d .  
 C o n s t   E R R O R _ E L E V A T I O N _ U S E R D E C L I N E D     =   1 2 8   ' B i t   # 8 .     C r i t i c a l   s c r i p t   e r r o r .   U s e r   d e c l i n e d   t o   a l l o w   m a n d a t o r y   s c r i p t   e l e v a t i o n  
 C o n s t   E R R O R _ E L E V A T I O N                               =   2 5 6   ' B i t   # 9 .     C r i t i c a l   s c r i p t   e r r o r .   T h e   a t t e m p t   t o   e l e v a t e   t h e   p r o c e s s   d i d   n o t   s u c c e e d  
 C o n s t   E R R O R _ S C R I P T I N I T                             =   5 1 2   ' B i t   # 1 0 .   C r i t i c a l   s c r i p t   e r r o r .   I n i t i a l i z a t i o n   f a i l e d  
 C o n s t   E R R O R _ R E L A U N C H                                 =   1 0 2 4 ' B i t   # 1 1 .   C r i t i c a l   s c r i p t   e r r o r .   T h i s   i s   a   t e m p o r a r y   v a l u e   a n d   m u s t   n o t   b e   t h e   f i n a l   r e t u r n   c o d e  
 C o n s t   E R R O R _ U N K N O W N                                   =   2 0 4 8 ' B i t   # 1 2   C r i t i c a l   s c r i p t   e r r o r .   S c r i p t   d i d   n o t   c o m p l e t e   i n   a   w e l l   d e f i n e d   s t a t e  
 C o n s t   E R R O R _ A L L                                           =   4 0 9 5 ' F u l l   B i t M a s k  
 C o n s t   E R R O R _ U S E R _ A B O R T                             =   & H C 0 0 0 0 1 3 A   ' R E S E R V E D .   D e c   - 1 0 7 3 7 4 1 5 1 0 .   C r i t i c a l   e r r o r .   R e t u r n e d   w h e n   u s e r   a b o r t s   w i t h   < C t r l > + < B r e a k >   o r   c l o s e s   t h e   c m d   w i n d o w  
 C o n s t   E R R O R _ S U C C E S S _ C O N F I G _ C O M P L E T E   =   1 7 2 8  
 C o n s t   E R R O R _ S U C C E S S _ R E B O O T _ R E Q U I R E D   =   3 0 1 0  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '  
 '       D e c l a r a t i o n   o f   v a r i a b l e s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 D i m   o F s o ,   o M s i ,   o R e g ,   o W S h e l l ,   o W m i L o c a l ,   o S h e l l A p p  
 D i m   C o m p u t e r I t e m ,   K e y ,   I t e m ,   L o g S t r e a m ,   T m p K e y  
 D i m   a r r V e r s i o n  
 D i m   d i c K e e p L i s ,   d i c A p p s ,   d i c K e e p F o l d e r ,   d i c D e l R e g K e y ,   d i c K e e p R e g  
 D i m   d i c I n s t a l l e d S k u ,   d i c R e m o v e S k u ,   d i c K e e p S k u ,   d i c C 2 R S u i t e ,   d i c D e l I n U s e  
 D i m   d i c D e l F o l d e r  
 D i m   s A p p D a t a ,   s S c r u b D i r ,   s P r o g r a m F i l e s ,   s P r o g r a m F i l e s X 8 6 ,   s C o m m o n P r o g r a m F i l e s  
 D i m   s A l l u s e r s P r o f i l e ,   s O S V e r s i o n ,   s W i n D i r ,   s W I C a c h e D i r ,   s C o m m o n P r o g r a m F i l e s X 8 6  
 D i m   s P r o g r a m D a t a ,   s P a c k a g e F o l d e r ,   s L o c a l A p p D a t a ,   s O I n s t a l l R o o t ,   s S k u R e m o v e L i s t  
 D i m   s O S i n f o ,   s D e f a u l t ,   s T e m p ,   s T m p ,   s C m d ,   s L o g D i r ,   s P r o m p t ,   s P r o f i l e s D i r e c t o r y  
 D i m   s R e t V a l ,   s S c r i p t D i r ,   s P a c k a g e G u i d ,   s V a l u e ,   s A c t i v e C o n f i g u r a t i o n  
 D i m   i V e r s i o n N T ,   i E r r o r ,   i P r o c C l o s e C n t  
 D i m   f 6 4 ,   f L o g I n i t i a l i z e d ,   f N o C a n c e l ,   f R e m o v e O s e ,   f D e t e c t O n l y ,   f Q u i e t ,   f F o r c e  
 D i m   f C 2 R ,   f R e m o v e A l l ,   f R e b o o t R e q u i r e d ,   f R e r u n ,   f S e t R u n O n c e ,   f T e s t R e r u n  
 D i m   f I s E l e v a t e d ,   f N o E l e v a t e ,   f U s e r C o n s e n t ,   f C S c r i p t  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '                                                                       M a i n  
 '  
 '                                                       M a i n   s e c t i o n   o f   s c r i p t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
  
 '   i n i t i a l i z e   r e q u i r e d   s e t t i n g s   a n d   o b j e c t s  
 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 I n i t i a l i z e  
  
 '   c a l l   t h e   c o m m a n d   l i n e   p a r s e r  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 P a r s e C m d L i n e  
  
                                                                 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
                                                                 '   S t a g e   #   0   -   B a s i c   d e t e c t i o n   |  
                                                                 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 L o g H   " S t a g e   #   0   "   &   c h r ( 3 4 )   &   " B a s i c   d e t e c t i o n "   &   c h r ( 3 4 )    
  
 '   e n s u r e   i n t e g r i t y   o f   W I   m e t a d a t a   w h i c h   c o u l d   f a i l   u s e d   A P I s   o t h e r w i s e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 L o g   " E n s u r e   W i n d o w s   I n s t a l l e r   m e t a d a t a   i n t e g r i t y   "   &   "   ( "   &   T i m e   &   " ) "  
 E n s u r e V a l i d W I M e t a d a t a   H K C U , " S o f t w a r e \ C l a s s e s \ I n s t a l l e r \ P r o d u c t s " ,   C O M P R E S S E D  
 E n s u r e V a l i d W I M e t a d a t a   H K C R , " I n s t a l l e r \ P r o d u c t s " ,   C O M P R E S S E D  
 E n s u r e V a l i d W I M e t a d a t a   H K L M , " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ I n s t a l l e r \ U s e r D a t a \ S - 1 - 5 - 1 8 \ P r o d u c t s " ,   C O M P R E S S E D  
 E n s u r e V a l i d W I M e t a d a t a   H K L M , " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ I n s t a l l e r \ U s e r D a t a \ S - 1 - 5 - 1 8 \ C o m p o n e n t s " ,   C O M P R E S S E D  
 E n s u r e V a l i d W I M e t a d a t a   H K C R , " I n s t a l l e r \ C o m p o n e n t s " ,   C O M P R E S S E D  
  
 '   b u i l d   a   l i s t   w i t h   i n s t a l l e d / r e g i s t e r e d   O f f i c e   p r o d u c t s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F i n d I n s t a l l e d O P r o d u c t s  
 I f   d i c C 2 R S u i t e . C o u n t   >   0   T h e n    
         L o g   " R e g i s t e r e d   A R P   p r o d u c t ( s )   f o u n d : "  
         F o r   E a c h   K e y   I n   d i c C 2 R S u i t e . K e y s  
         	 L o g   "   -   "   &   K e y   &   "   -   "   &   d i c C 2 R S u i t e . I t e m ( K e y )  
         N e x t   ' K e y  
 '         F o r   E a c h   I t e m   i n   d i c C 2 R S u i t e . I t e m s  
 '                 L o g   "   -   "   &   I t e m  
 '         N e x t   ' I t e m  
 E l s e  
         L o g   " N o   r e g i s t e r e d   p r o d u c t ( s )   f o u n d "  
 E n d   I f  
  
 '   l o c a t e   t h e   C 2 R   % P a c k a g e F o l d e r %   a n d   t h e   P a c k a g e G u i d  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 s P a c k a g e F o l d e r   =   " "  
 I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e F o l d e r   =   s V a l u e  
 E l s e I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s P a c k a g e F o l d e r ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e F o l d e r   =   s V a l u e  
 E l s e I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s P a c k a g e F o l d e r ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e F o l d e r   =   s V a l u e  
 E n d   I f  
 '   i f   s P a c k a g e F o l d e r   i s   i n v a l i d   s e t   i t   t o   t h e   c 2 r   r e g i s t r y   r e f e r e n c e   s t r i n g  
 I f   N O T   L e n ( s P a c k a g e F o l d e r )   >   0   O R   I s N u l l ( s P a c k a g e F o l d e r )   T h e n    
 	 I f   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e   1 5 " )   T h e n  
 	 	 s P a c k a g e F o l d e r   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e   1 5 "  
 	 E l s e I f   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e   1 6 " )   T h e n  
 	 	 s P a c k a g e F o l d e r   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e   1 6 "  
 	 E l s e I f   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s " )   T h e n  
 	 	 s P a c k a g e F o l d e r   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e "  
 	 E l s e I f   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s ( x 8 6 ) % " )   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s " )   T h e n  
 	 	 s P a c k a g e F o l d e r   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s ( x 8 6 ) % " )   &   " \ M i c r o s o f t   O f f i c e "  
 	 E n d   I f  
 E n d   I f  
  
 s P a c k a g e G u i d   =   " "  
 I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e G u i d   =   s V a l u e  
 E l s e I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e G u i d   =   s V a l u e  
 E l s e I f   R e g R e a d V a l u e ( H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
 	 s P a c k a g e G u i d   =   s V a l u e  
 E n d   I f  
  
 '   I n i t   c o m p l e t e .   R e s e t   t h e   r e t u r n   v a l u e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 C l e a r E r r o r   E R R O R _ S C R I P T I N I T  
  
  
                                                                 ' - - - - - - - - - - - - - - - - - - - - - - -  
                                                                 '   S t a g e   #   1   -   U n i n s t a l l   |  
                                                                 ' - - - - - - - - - - - - - - - - - - - - - - -  
  
 L o g H   " S t a g e   #   1   "   &   c h r ( 3 4 )   &   " U n i n s t a l l "   &   c h r ( 3 4 )  
  
 '   c l e a n   O 1 5   S P P  
 ' - - - - - - - - - - - - - -  
 L o g H 1   " C l e a n   O S P P "    
 C l e a n O S P P  
  
 '   e n d   a l l   r u n n i n g   O f f i c e   a p p l i c a t i o n s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 L o g H 1   " E n d   r u n n i n g   p r o c e s s e s "    
 C l o s e O f f i c e A p p s  
  
 '   r e m o v e   s c h e d u l e d   t a s k s   w h i c h   m i g h t   i n t e r f e r e   w i t h   u n i n s t a l l  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 D e l S c h t a s k s  
  
 '   u n p i n   s h o r t c u t s  
 ' - - - - - - - - - - - - - - - -  
 '   n e e d   t o   u n p i n   a s   l o n g   a s   t h e   s h o r t c u t s   a r e   s t i l l   v a l i d !  
 L o g H 1   " U n p i n n i n g   s h o r t c u t s "    
 C l e a n S h o r t c u t s   s A l l u s e r s P r o f i l e ,   T r u e ,   T r u e  
 C l e a n S h o r t c u t s   s P r o f i l e s D i r e c t o r y ,   T r u e ,   T r u e  
  
 '   u n i n s t a l l  
 ' - - - - - - - - - -  
 L o g H 1   " R e m o v i n g   "   &   O N A M E      
 U n i n s t a l l  
  
                                                                 ' - - - - - - - - - - - - - - - - - - - - -  
                                                                 '   S t a g e   #   2   -   C l e a n U p   |  
                                                                 ' - - - - - - - - - - - - - - - - - - - - -  
 L o g H   " S t a g e   #   2   "   &   c h r ( 3 4 )   &   " C l e a n U p "   &   c h r ( 3 4 )  
  
 '   C l e a n u p   r e g i s t r y   d a t a  
 ' - - - - - - - - - - - - - - - - - - - - - -  
 R e g W i p e  
  
 '   C l e a n u p   f i l e s  
 ' - - - - - - - - - - - - - -  
 F i l e W i p e  
  
 '   f o r   t e s t   p u r p o s e s   o n l y !  
 I f   f T e s t R e r u n   T h e n  
         L o g H 2   " E n f o r c i n g   ' R e r u n '   m o d e   f o r   t e s t   p u r p o s e s "  
         f R e b o o t R e q u i r e d   =   T r u e  
         S e t E r r o r   E R R O R _ R E B O O T _ R E Q U I R E D  
         R e r u n  
 E n d   I f  
  
 E x i t S c r i p t  
  
 S u b   E x i t S c r i p t  
  
                                                                         ' - - - - - - - - - - - - - - - - - -  
                                                                         '   S t a g e   #   3   -   E x i t   |  
                                                                         ' - - - - - - - - - - - - - - - - - -  
         '   U p d a t e   c a c h e d   e r r o r   a n d   q u i t  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         I f   N O T   C B o o l ( i E r r o r   A N D   ( E R R O R _ F A I L   +   E R R O R _ I N C O M P L E T E ) )   T h e n   R e g D e l e t e V a l u e   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l e a n C 2 R " ,   " R e r u n " ,   F a l s e  
         S e t R e t V a l   i E r r o r  
  
         '   l o g   r e s u l t  
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ I N C O M P L E T E )   T h e n    
                 L o g H 2   " R e m o v a l   r e s u l t :   "   &   i E r r o r   &   "   -   I N C O M P L E T E .   U n i n s t a l l   r e q u i r e s   a   s y s t e m   r e b o o t   t o   c o m p l e t e . "  
         E l s e  
                 s T m p   =   "   -   S U C C E S S "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   s T m p   =   "   -   U S E R   C A N C E L E D "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ F A I L )   T h e n   s T m p   =   "   -   F A I L "  
                 L o g H 2   " R e m o v a l   r e s u l t :   "   &   i E r r o r   &   s T m p  
         E n d   I f  
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ F A I L )   T h e n  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ R E B O O T _ R E Q U I R E D )   T h e n   L o g   "   -   R e b o o t   r e q u i r e d "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   L o g   "   -   U s e r   c a n c e l "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ S T A G E 1 )   T h e n   L o g   "   -   M s i e x e c   f a i l e d "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ S T A G E 2 )   T h e n   L o g   "   -   C l e a n u p   f a i l e d "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ I N C O M P L E T E )   T h e n   L o g   "   -   R e m o v a l   i n c o m p l e t e .   R e r u n   a f t e r   r e b o o t   n e e d e d "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ D C A F _ F A I L U R E )   T h e n   L o g   "   -   S e c o n d   a t t e m p t   c l e a n u p   s t i l l   i n c o m p l e t e "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ E L E V A T I O N _ U S E R D E C L I N E D )   T h e n   L o g   "   -   U s e r   d e c l i n e d   e l e v a t i o n "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ E L E V A T I O N )   T h e n   L o g   "   -   E l e v a t i o n   f a i l e d "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ S C R I P T I N I T )   T h e n   L o g   "   -   I n i t i a l i z a t i o n   e r r o r "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ R E L A U N C H )   T h e n   L o g   "   -   U n h a n d l e d   e r r o r   d u r i n g   r e l a u n c h   a t t e m p t "  
                 I f   C B o o l ( i E r r o r   A N D   E R R O R _ U N K N O W N )   T h e n   L o g   "   -   U n k n o w n   e r r o r "  
                 '   E R R O R _ U S E R _ A B O R T   i s   o n l y   v a l i d   f o r   t h e   t e m p o r a r y   c a c h e d   e r r o r   f i l e  
                 ' I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R _ A B O R T )   T h e n   L o g   "   -   P r o c e s s   t e r m i n a t e d   b y   u s e r "  
         E n d   I f  
  
         L o g H 2   " R e m o v a l   e n d . "    
  
         '   R e b o o t   h a n d l i n g  
         I f   f R e b o o t R e q u i r e d   T h e n  
                 s P r o m p t   =   " I n   o r d e r   t o   c o m p l e t e   u n i n s t a l l ,   a   s y s t e m   r e b o o t   i s   n e c e s s a r y .   W o u l d   y o u   l i k e   t o   r e b o o t   n o w ? "  
                 I f   N O T   f Q u i e t   T h e n  
                         I f   M s g B o x ( s P r o m p t ,   v b Y e s N o ,   S C R I P T N A M E   &   "   -   R e b o o t   R e q u i r e d " )   =   V B _ Y E S   T h e n  
                                 D i m   c o l O S ,   o O S  
                                 D i m   o W m i R e b o o t  
                                 S e t   o W m i R e b o o t   =   G e t O b j e c t ( " w i n m g m t s : { i m p e r s o n a t i o n L e v e l = i m p e r s o n a t e , ( S h u t d o w n ) } ! \ \ . \ r o o t \ c i m v 2 " )  
                                 S e t   c o l O S   =   o W m i R e b o o t . E x e c Q u e r y   ( " S e l e c t   *   f r o m   W i n 3 2 _ O p e r a t i n g S y s t e m " )  
                                 F o r   E a c h   o O S   i n   c o l O S  
                                         o O S . R e b o o t ( )  
                                 N e x t  
                         E n d   I f  
                 E n d   I f  
         E n d   I f  
  
         w s c r i p t . q u i t   i E r r o r  
 E n d   S u b   ' E x i t S c r i p t  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '                                                                     E n d     M a i n  
 '  
 '                                                       E n d   o f   M a i n   s e c t i o n  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       I n i t i a l i z e  
 '  
 '       C o n f i g u r e   d e f a u l t s   a n d   i n i t i a l i z e   a l l   r e q u i r e d   o b j e c t s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   I n i t i a l i z e   ( )  
         D i m   i C n t  
  
         '   s e t   d e f a u l t s  
         ' - - - - - - - - - - - - -  
         i E r r o r   =   E R R O R _ S U C C E S S  
         i P r o c C l o s e C n t   =   0  
         s L o g D i r   =   " "  
         s P a c k a g e F o l d e r   =   " "  
         f 6 4   =   F a l s e  
         f C S c r i p t   =   F a l s e  
         f L o g I n i t i a l i z e d   =   F a l s e  
         f N o C a n c e l   =   F a l s e  
         f R e m o v e O s e   =   F a l s e  
         f D e t e c t O n l y   =   F a l s e  
         f Q u i e t   =   F a l s e  
         f F o r c e   =   F a l s e  
         f C 2 R   =   T r u e  
         f R e b o o t R e q u i r e d   =   F a l s e  
         f R e r u n   =   F a l s e  
         f T e s t R e r u n   =   F a l s e  
         f I s E l e v a t e d   =   F a l s e  
         f N o E l e v a t e   =   F a l s e  
         f S e t R u n O n c e   =   F a l s e  
         f U s e r C o n s e n t   =   F a l s e  
  
         '   c r e a t e   r e q u i r e d   o b j e c t s  
         ' - - - - - - - - - - - - - - - - - - - - - - - -  
         S e t   o W m i L o c a l       =   G e t O b j e c t ( " w i n m g m t s : \ \ . \ r o o t \ c i m v 2 " )  
         S e t   o W S h e l l           =   C r e a t e O b j e c t ( " W s c r i p t . S h e l l " )  
         S e t   o S h e l l A p p       =   C r e a t e O b j e c t ( " S h e l l . A p p l i c a t i o n " )  
         S e t   o F s o                 =   C r e a t e O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )  
         S e t   o M s i                 =   C r e a t e O b j e c t ( " W i n d o w s I n s t a l l e r . I n s t a l l e r " )  
         S e t   o R e g                 =   G e t O b j e c t ( " w i n m g m t s : \ \ . \ r o o t \ d e f a u l t : S t d R e g P r o v " )  
  
         '   g e t   e n v i r o n m e n t   p a t h   v a l u e s  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         s A p p D a t a                         =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % a p p d a t a % " )  
         s L o c a l A p p D a t a               =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % l o c a l a p p d a t a % " )  
         s T e m p                               =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % t e m p % " )  
         s A l l U s e r s P r o f i l e         =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % a l l u s e r s p r o f i l e % " )  
         R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s   N T \ C u r r e n t V e r s i o n \ P r o f i l e L i s t " ,   " P r o f i l e s D i r e c t o r y " ,   s P r o f i l e s D i r e c t o r y ,   " R E G _ E X P A N D _ S Z "  
         I f   N O T   o F s o . F o l d e r E x i s t s ( s P r o f i l e s D i r e c t o r y )   T h e n    
                 s P r o f i l e s D i r e c t o r y     =   o F s o . G e t P a r e n t F o l d e r N a m e ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % u s e r p r o f i l e % " ) )  
         E n d   I f  
         s P r o g r a m F i l e s               =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )  
         ' s P r o g r a m F i l e s X 8 6       =   d e f e r r e d .   D e p e n d s   o n   o p e r a t i n g   s y s t e m   a r c h i t e c t u r e   c h e c k  
         s C o m m o n P r o g r a m F i l e s   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % c o m m o n p r o g r a m f i l e s % " )  
         ' s C o m m o n P r o g r a m F i l e s X 8 6   =   d e f e r r e d .   D e p e n d s   o n   o p e r a t i n g   s y s t e m   a r c h i t e c t u r e   c h e c k  
         s P r o g r a m D a t a                 =   o W S H e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m d a t a % " )  
         s W i n D i r                           =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % w i n d i r % " )  
         ' s P a c k a g e F o l d e r             =   d e f e r r e d  
         s W I C a c h e D i r                   =   s W i n D i r   &   " \ "   &   " I n s t a l l e r "  
         s S c r u b D i r                       =   s T e m p   &   " \ "   &   S C R I P T N A M E  
         s S c r i p t D i r                     =   w s c r i p t . S c r i p t F u l l N a m e  
         s S c r i p t D i r                     =   L e f t ( s S c r i p t D i r ,   I n S t r R e v ( s S c r i p t D i r ,   " \ " ) )  
  
         '   e n s u r e   6 4   b i t   h o s t   i f   n e e d e d  
         I f   I n S t r ( L C a s e ( w s c r i p t . p a t h ) ,   " s y s w o w 6 4 " )   >   0   T h e n   R e l a u n c h A s 6 4 H o s t  
  
         '   c r e a t e   t h e   t e m p   f o l d e r  
         ' - - - - - - - - - - - - - - - - - - - - - - -  
         I f   N o t   o F s o . F o l d e r E x i s t s ( s S c r u b D i r )   T h e n   o F s o . C r e a t e F o l d e r   s S c r u b D i r  
  
         '   s e t   t h e   d e f a u l t   l o g g i n g   d i r e c t o r y  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         s L o g D i r   =   s S c r u b D i r  
  
         '   d e t e c t   b i t n e s s   o f   t h e   o p e r a t i n g   s y s t e m  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         S e t   C o m p u t e r I t e m   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   f r o m   W i n 3 2 _ C o m p u t e r S y s t e m " )  
         F o r   E a c h   I t e m   I n   C o m p u t e r I t e m  
                 f 6 4   =   I n s t r ( L e f t ( I t e m . S y s t e m T y p e ,   3 ) ,   " 6 4 " )   >   0  
         N e x t  
         I f   f 6 4   T h e n   s P r o g r a m F i l e s X 8 6   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s ( x 8 6 ) % " )  
         I f   f 6 4   T h e n   s C o m m o n P r o g r a m F i l e s X 8 6   =   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % C o m m o n P r o g r a m F i l e s ( x 8 6 ) % " )  
  
         '   u p d a t e   e r r o r   f l a g  
         ' - - - - - - - - - - - - - - - - - -  
         S e t E r r o r   E R R O R _ S C R I P T I N I T  
  
         '   g e t   W i n 3 2 _ O p e r a t i n g S y s t e m   d e t a i l s  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         S e t   C o m p u t e r I t e m   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   f r o m   W i n 3 2 _ O p e r a t i n g S y s t e m " )  
         F o r   E a c h   I t e m   i n   C o m p u t e r I t e m    
                 s O S i n f o   =   s O S i n f o   &   I t e m . C a p t i o n    
                 s O S i n f o   =   s O S i n f o   &   I t e m . O t h e r T y p e D e s c r i p t i o n  
                 s O S i n f o   =   s O S i n f o   &   " ,   "   &   " S P   "   &   I t e m . S e r v i c e P a c k M a j o r V e r s i o n  
                 s O S i n f o   =   s O S i n f o   &   " ,   "   &   " V e r s i o n :   "   &   I t e m . V e r s i o n  
                 s O s V e r s i o n   =   I t e m . V e r s i o n  
                 s O S i n f o   =   s O S i n f o   &   " ,   "   &   " C o d e p a g e :   "   &   I t e m . C o d e S e t  
                 s O S i n f o   =   s O S i n f o   &   " ,   "   &   " C o u n t r y   C o d e :   "   &   I t e m . C o u n t r y C o d e  
                 s O S i n f o   =   s O S i n f o   &   " ,   "   &   " L a n g u a g e :   "   &   I t e m . O S L a n g u a g e  
         N e x t  
  
         '   g e t   V e r s i o n N T   n u m b e r  
         ' - - - - - - - - - - - - - - - - - - - - -  
         a r r V e r s i o n   =   S p l i t ( s O s V e r s i o n ,   D e l i m i t e r ( s O s V e r s i o n ) )  
         i V e r s i o n N t   =   C I n t ( a r r V e r s i o n ( 0 ) )   *   1 0 0   +   C I n t ( a r r V e r s i o n ( 1 ) )  
  
         '   e n s u r e   s u f f i c i e n t   r e g i s t r y   p e r m i s i o n s  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         f I s E l e v a t e d   =   C h e c k R e g P e r m i s s i o n s  
         I f   N O T   f I s E l e v a t e d   A N D   N O T   f N o E l e v a t e   T h e n  
                 '   t r y   t o   r e l a u n c h   e l e v a t e d  
                 R e l a u n c h E l e v a t e d  
  
                 '   c a n ' t   r e l a u n c h .   E x i t   o u t  
                 S e t E r r o r   E R R O R _ E L E V A T I O N  
                 I f   U C a s e ( M i d ( W s c r i p t . F u l l N a m e ,   L e n ( W s c r i p t . P a t h )   +   2 ,   1 ) )   =   " C "   T h e n  
                         I f   N o t   f L o g I n i t i a l i z e d   T h e n   C r e a t e L o g  
                         L o g   " E r r o r :   I n s u f f i c i e n t   r e g i s t r y   a c c e s s   p e r m i s s i o n s   -   e x i t i n g "  
                 E n d   I f  
                 S e t R e t V a l   i E r r o r  
                 w s c r i p t . q u i t   i E r r o r  
         E n d   I f  
  
         '   c l e a r   e r r o r   f l a g s  
         ' - - - - - - - - - - - - - - - - - -  
         C l e a r E r r o r   E R R O R _ E L E V A T I O N  
         C l e a r E r r o r   E R R O R _ S C R I P T I N I T  
  
         '   e n s u r e   C S c r i p t   a s   e n g i n e  
         ' - - - - - - - - - - - - - - - - - - - - - - - -  
         f C S c r i p t   =   U C a s e ( M i d ( W s c r i p t . F u l l N a m e ,   L e n ( W s c r i p t . P a t h )   +   2 ,   1 ) )   =   " C "  
         I f   N O T   f C S c r i p t   A N D   N O T   f Q u i e t   T h e n   R e l a u n c h A s C S c r i p t  
  
         '   s e t   r e t v a l   f o r   f i l e   b a s e d   l o g i c  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         '   v a l u e   n e e d s   t o   b e   k e p t   o n   ' u s e r   a b o r t '  
         S e t R e t V a l   E R R O R _ U S E R _ A B O R T  
  
         '   c r e a t e   d i c t i o n a r y   o b j e c t s  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - -  
         S e t   d i c I n s t a l l e d S k u   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c R e m o v e S k u   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c K e e p S k u   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c K e e p L i s   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c K e e p F o l d e r   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c A p p s   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c D e l R e g K e y   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c K e e p R e g   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c C 2 R S u i t e   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c D e l I n U s e   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         S e t   d i c D e l F o l d e r   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
  
         '   a d d   i n i t i a l   k n o w n   . e x e   f i l e s   t h a t   n e e d   t o   b e   c l o s e d  
         ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
         d i c A p p s . A d d   " a p p v s h n o t i f y . e x e " ,   " a p p v s h n o t i f y . e x e "  
         d i c A p p s . A d d   " i n t e g r a t e d o f f i c e . e x e " ,   " i n t e g r a t e d o f f i c e . e x e "  
         d i c A p p s . A d d   " i n t e g r a t o r . e x e " ,   " i n t e g r a t o r . e x e "  
         d i c A p p s . A d d   " f i r s t r u n . e x e " ,   " f i r s t r u n . e x e "  
         d i c A p p s . A d d   " s e t u p . e x e " ,   " s e t u p . e x e "  
         d i c A p p s . A d d   " c o m m u n i c a t o r . e x e " ,   " c o m m u n i c a t o r . e x e "  
         d i c A p p s . A d d   " m s o s y n c . e x e " ,   " m s o s y n c . e x e "  
         d i c A p p s . A d d   " O n e N o t e M . e x e " ,   " O n e N o t e M . e x e "  
         d i c A p p s . A d d   " i e x p l o r e . e x e " ,   " i e x p l o r e . e x e "  
         d i c A p p s . A d d   " m a v i n j e c t 3 2 . e x e " ,   " m a v i n j e c t 3 2 . e x e "  
         d i c A p p s . A d d   " w e r f a u l t . e x e " ,   " w e r f a u l t . e x e "  
         d i c A p p s . A d d   " p e r f b o o s t . e x e " ,   " p e r f b o o s t . e x e "  
         d i c A p p s . A d d   " r o a m i n g o f f i c e . e x e " ,   " r o a m i n g o f f i c e . e x e "  
         '   S P 1   a d d i t i o n s   /   c h a n g e s  
         d i c A p p s . A d d   " o f f i c e c l i c k t o r u n . e x e " ,   " o f f i c e c l i c k t o r u n . e x e "  
         d i c A p p s . A d d   " o f f i c e o n d e m a n d . e x e " ,   " o f f i c e o n d e m a n d . e x e "  
         d i c A p p s . A d d   " O f f i c e C 2 R C l i e n t . e x e " ,   " O f f i c e C 2 R C l i e n t . e x e "  
  
 E n d   S u b   ' I n i t i a l i z e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       P a r s e C m d L i n e  
 '  
 '       C o m m a n d   l i n e   p a r s e r  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   P a r s e C m d L i n e  
  
         D i m   i C n t ,   i A r g C n t  
         D i m   a r r A r g u m e n t s  
         D i m   s A r g 0  
          
         i A r g C n t   =   W s c r i p t . A r g u m e n t s . C o u n t  
         I f   i A r g C n t   >   0   T h e n  
                 I f   w s c r i p t . A r g u m e n t s ( 0 )   =   " U A C "   T h e n  
                         I f   w s c r i p t . a r g u m e n t s . c o u n t   =   1   T h e n   i A r g C n t   =   0  
                 E n d   I f  
         E n d   I f  
         I f   i A r g C n t   =   0   T h e n  
                 S e l e c t   C a s e   U C a s e ( w s c r i p t . S c r i p t N a m e )  
                 C a s e   E l s e  
                         ' C r e a t e   t h e   l o g  
                         C r e a t e L o g  
                         F i n d I n s t a l l e d O P r o d u c t s  
                         s D e f a u l t   =   " A L L "  
                         a r r A r g u m e n t s   =   S p l i t ( T r i m ( s D e f a u l t ) ,   "   " )  
                         I f   U B o u n d ( a r r A r g u m e n t s )   =   - 1   T h e n   R e D i m   a r r A r g u m e n t s ( 0 )  
                 E n d   S e l e c t  
         E l s e  
                 R e D i m   a r r A r g u m e n t s ( i A r g C n t - 1 )  
                 F o r   i C n t   =   0   T o   ( i A r g C n t - 1 )  
                         a r r A r g u m e n t s ( i C n t )   =   U C a s e ( W s c r i p t . A r g u m e n t s ( i C n t ) )  
                 N e x t   ' i C n t  
         E n d   I f   ' i A r g C n t   =   0  
  
         '   h a r d c o d e   t o   f u l l   r e m o v a l  
         s A r g 0   =   " A L L "  
  
         S e l e c t   C a s e   U C a s e ( s A r g 0 )  
         C a s e   " ? "  
                 S h o w S y n t a x  
         C a s e   " A L L "  
                 f R e m o v e A l l   =   T r u e  
                 f R e m o v e O s e   =   F a l s e  
         C a s e   " C 2 R "  
                 f C 2 R   =   T r u e  
                 f R e m o v e A l l   =   F a l s e  
                 f R e m o v e O s e   =   F a l s e  
         C a s e   E l s e  
                 f R e m o v e A l l   =   F a l s e  
                 f R e m o v e O s e   =   F a l s e  
                 s S k u R e m o v e L i s t   =   s A r g 0  
         E n d   S e l e c t  
          
         F o r   i C n t   =   0   T o   U B o u n d ( a r r A r g u m e n t s )  
                 S e l e c t   C a s e   a r r A r g u m e n t s ( i C n t )  
                 C a s e   " ? " ,   " / ? " ,   " - ? "  
                         S h o w S y n t a x  
                 C a s e   " / L " ,   " / L O G "  
                         f L o g I n i t i a l i z e d   =   F a l s e  
                         I f   U B o u n d ( a r r A r g u m e n t s )   >   i C n t   T h e n  
                                 I f   o F s o . F o l d e r E x i s t s ( a r r A r g u m e n t s ( i C n t   +   1 ) )   T h e n    
                                         s L o g D i r   =   a r r A r g u m e n t s ( i C n t   +   1 )  
                                 E l s e  
                                         O n   E r r o r   R e s u m e   N e x t  
                                         o F s o . C r e a t e F o l d e r ( a r r A r g u m e n t s ( i C n t   +   1 ) )  
                                         I f   E r r   < >   0   T h e n   s L o g D i r   =   s S c r u b D i r   E l s e   s L o g D i r   =   a r r A r g u m e n t s ( i C n t   +   1 )  
                                 E n d   I f  
                         E n d   I f  
                 C a s e   " / N " ,   " / N O C A N C E L "  
                         f N o C a n c e l   =   T r u e  
                  
                 C a s e   " / N E " ,   " / N O E L E V A T E "  
                         f N o E l e v a t e   =   T r u e  
  
                 C a s e   " / O " ,   " / O S E "  
                         f R e m o v e O s e   =   T r u e  
                  
                 C a s e   " / Q " ,   " / Q U I E T "  
                         f Q u i e t   =   T r u e  
                  
                 '   f o r   t e s t   p u r p o s e s   o n l y !  
                 C a s e   " / T R " ,   " / T E S T R E R U N "  
                         f T e s t R e r u n   =   T r u e  
                 C a s e   E l s e  
                 E n d   S e l e c t  
         N e x t   ' i C n t  
         I f   N o t   f L o g I n i t i a l i z e d   T h e n   C r e a t e L o g  
 E n d   S u b   ' P a r s e C m d L i n e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S h o w S y n t a x  
 '  
 '       S h o w   t h e   e x p e c t e d   s y n t a x   f o r   t h e   s c r i p t   u s a g e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S h o w S y n t a x  
         W s c r i p t . E c h o   s E r r   &   v b C r L f   &   _  
                           S C R I P T F I L E   &   "   V   "   &   S C R I P T V E R S I O N   &   v b C r L f   &   _  
                           " C o p y r i g h t   ( c )   M i c r o s o f t   C o r p o r a t i o n .   A l l   R i g h t s   R e s e r v e d "   &   v b C r L f   &   v b C r L f   &   _  
                           S C R I P T F I L E   &   "   -   R e m o v e   "   &   O N A M E   &   v b C r L f   &   _  
                           " w h e n   a   r e g u l a r   u n i n s t a l l   i s   n o   l o n g e r   p o s s i b l e "   &   v b C r L f   &   v b C r L f   &   _  
                           " U s a g e : "   &   v b T a b   &   S C R I P T F I L E   &   v b C r L f   &   v b C r L f   &   _  
                           v b T a b   &   " / ?                                                               '   D i s p l a y s   t h i s   h e l p " &   v b C r L f  
         W s c r i p t . Q u i t  
 E n d   S u b   ' S h o w S y n t a x  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       F i n d I n s t a l l e d O P r o d u c t s  
 '  
 '       O f f i c e   c o n f i g u r a t i o n   p r o d u c t s   a r e   l i s t e d   w i t h   t h e i r   c o n f i g u r a t i o n   p r o d u c t  
 '       n a m e   i n   t h e   " U n i n s t a l l "   k e y .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   F i n d I n s t a l l e d O P r o d u c t s  
         D i m   A r p I t e m ,   p r o d ,   c u l t  
         D i m   s C u r K e y ,   s V a l u e ,   s C o n f i g N a m e ,   s C u l t u r e ,   s D i s p l a y V e r s i o n ,   s P r o d  
         D i m   s U n i n s t a l l S t r i n g  
         D i m   i L e f t ,   i R i g h t  
         D i m   a r r K e y s ,   a r r P r o d u c t s ,   a r r C u l t u r e s  
         D i m   f S y s t e m C o m p o n e n t 0 ,   f D i s p l a y V e r s i o n ,   f U n i n s t a l l S t r i n g  
  
 	 C o n s t   R E G _ A R P                                   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ U n i n s t a l l \ "  
 	 C o n s t   R E G _ O 1 5 R P R O P E R T Y B A G           =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n \ p r o p e r t y B a g \ "  
 	 C o n s t   R E G _ O 1 5 C 2 R C O N F I G U R A T I O N   =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n \ C o n f i g u r a t i o n \ "  
 	 C o n s t   R E G _ O 1 5 C 2 R P R O D U C T I D S         =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n \ P r o d u c t R e l e a s e I D s \ A c t i v e \ "  
 	 C o n s t   R E G _ O 1 6 C 2 R C O N F I G U R A T I O N   =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n \ C o n f i g u r a t i o n \ "  
 	 C o n s t   R E G _ O 1 6 C 2 R P R O D U C T I D S         =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n \ P r o d u c t R e l e a s e I D s \ A c t i v e \ "  
 	 C o n s t   R E G _ C 2 R C O N F I G U R A T I O N         =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n \ C o n f i g u r a t i o n \ "  
 	 C o n s t   R E G _ C 2 R P R O D U C T I D S               =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n \ P r o d u c t R e l e a s e I D s \ "  
  
  
         I f   d i c I n s t a l l e d S k u . C o u n t   >   0   T h e n   E x i t   S u b   ' A l r e a d y   d o n e   f r o m   c o m m a n d   l i n e   p a r s e r  
          
         f D i s p l a y V e r s i o n   =   F a l s e  
  
         '   i d e n t i f y   C 2 R   p r o d u c t s  
         L o g O n l y   v b C r L f   &   " D e t e c t i n g   i n s t a l l e d   p r o d u c t s   "  
          
 	 L o g O n l y   " C h e c k   f o r   O 1 5   C 2 R   p r o d u c t s "  
 	 '   C h e c k   O 1 5   C o n f i g u r a t i o n   k e y  
         I f   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 5 C 2 R C O N F I G U R A T I O N ,   " P r o d u c t R e l e a s e I d s " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
                 a r r P r o d u c t s   =   S p l i t ( s V a l u e ,   " , " )  
                 f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 5 C 2 R P R O D U C T I D S   &   " c u l t u r e " ,   " x - n o n e " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
                 I f   N O T   E r r   =   0   T h e n  
                         E r r . C l e a r  
                 E l s e  
                         '   g e t   v e r s i o n   f r o m   a c t i v e   w i t h   f a l l b a c k   o n   c o n f i g u r a t i o n  
                         F o r   E a c h   p r o d   i n   a r r P r o d u c t s  
                                 L o g O n l y   " F o u n d   O 1 5   C 2 R   p r o d u c t   i n   C o n f i g u r a t i o n :   "   &   p r o d  
                                 '   u p d a t e   p r o d u c t   d i c t i o n a r y  
                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( p r o d ) )   T h e n  
                                 	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   L C a s e ( p r o d )  
                                 	 d i c I n s t a l l e d S k u . A d d   L C a s e ( p r o d ) ,   s D i s p l a y V e r s i o n  
                                 E n d   I f  
                         N e x t   ' p r o d  
                 E n d   I f  
         E n d   I f  
          
         '   C h e c k   O 1 5   P r o p e r t y B a g   k e y  
         I f   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 5 R P R O P E R T Y B A G ,   " p r o d u c t r e l e a s e i d " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
                 a r r P r o d u c t s   =   S p l i t ( s V a l u e ,   " , " )  
                 f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 5 C 2 R P R O D U C T I D S   &   " c u l t u r e " ,   " x - n o n e " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
                 I f   N O T   E r r   =   0   T h e n  
                         E r r . C l e a r  
                 E l s e  
                         F o r   E a c h   p r o d   i n   a r r P r o d u c t s  
                                 L o g O n l y   " F o u n d   O 1 5   C 2 R   p r o d u c t   i n   P r o p e r t y B a g :   "   &   p r o d  
                                 '   u p d a t e   p r o d u c t   d i c t i o n a r y  
                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( p r o d ) )   T h e n  
                                 	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   L C a s e ( p r o d )  
                                 	 d i c I n s t a l l e d S k u . A d d   L C a s e ( p r o d ) ,   s D i s p l a y V e r s i o n  
                                 E n d   I f  
                         N e x t   ' p r o d  
                 E n d   I f  
         E n d   I f  
          
 	 ' O 1 6   s e c t i o n  
 	 L o g O n l y   " C h e c k   f o r   O f f i c e   C 2 R   p r o d u c t s   ( > = Q R 8 ) "  
 	 '   C h e c k   O f f i c e   C o n f i g u r a t i o n   k e y  
         I f   R e g R e a d V a l u e ( H K L M ,   R E G _ C 2 R P R O D U C T I D S ,   " A c t i v e C o n f i g u r a t i o n " ,   s A c t i v e C o n f i g u r a t i o n ,   " R E G _ S Z " )   T h e n  
         	 '   G e t   D i s p l a y V e r s i o n  
         	 ' T r y   Q R 8   l o g i c   f i r s t  
 	 	 f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ C 2 R P R O D U C T I D S   &   s A c t i v e C o n f i g u r a t i o n   &   " \ c u l t u r e " ,   " x - n o n e " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
         	 I f   R e g E n u m K e y ( H K L M ,   R E G _ C 2 R P R O D U C T I D S   &   s A c t i v e C o n f i g u r a t i o n   &   " \ c u l t u r e " ,   a r r C u l t u r e s )   T h e n  
         	 	 F o r   E a c h   c u l t   I n   a r r C u l t u r e s  
         	 	 	 I f   I n S t r ( L C a s e ( c u l t ) ,   " x - n o n e " )   >   0   T h e n  
         	 	 	 	 f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ C 2 R P R O D U C T I D S   &   s A c t i v e C o n f i g u r a t i o n   &   " \ c u l t u r e \ "   &   c u l t ,   " V e r s i o n " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
         	 	 	 E n d   I f  
         	 	 N e x t   ' c u l t  
         	 E n d   I f    
         	 '   U p d a t e   p r o d u c t   d i c  
         	 I f   R e g E n u m K e y ( H K L M ,   R E G _ C 2 R P R O D U C T I D S   &   s A c t i v e C o n f i g u r a t i o n ,   a r r P r o d u c t s )   T h e n  
         	 	 F o r   E a c h   p r o d   I n   a r r P r o d u c t s  
         	 	 	 s P r o d   =   L C a s e ( p r o d )  
         	 	 	 I f   I n S t r ( s P r o d ,   " . " )   >   0   T h e n   s P r o d   =   L e f t ( s P r o d ,   I n S t r ( s P r o d ,   " . " )   -   1 )  
         	 	 	 S e l e c t   C a s e   L C a s e ( s P r o d )  
         	 	 	 C a s e   " c u l t u r e " ,   " s t r e a m "  
         	 	 	 C a s e   E l s e  
 	                                 L o g O n l y   " F o u n d   O f f i c e   C 2 R   p r o d u c t   i n   C o n f i g u r a t i o n :   "   &   p r o d  
 	                                 '   u p d a t e   p r o d u c t   d i c t i o n a r y  
 	                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( s P r o d )   T h e n  
 	 	                                 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   s P r o d  
 	                                 	 d i c I n s t a l l e d S k u . A d d   s P r o d ,   s D i s p l a y V e r s i o n  
 	                                 E n d   I f  
         	 	 	 E n d   S e l e c t  
         	 	 N e x t   ' p r o d  
         	 E n d   I f   ' a r r P r o d u c t s  
         E n d   I f   ' A c t i v e C o n f i g u r a t i o n  
  
 	 L o g O n l y   " C h e c k   f o r   O f f i c e   C 2 R   p r o d u c t s   ( Q R 7 ) "  
 	 '   C h e c k   O f f i c e   C o n f i g u r a t i o n   k e y  
 	 I f   R e g R e a d V a l u e ( H K L M ,   R E G _ C 2 R C O N F I G U R A T I O N ,   " P r o d u c t R e l e a s e I d s " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
 	         a r r P r o d u c t s   =   S p l i t ( s V a l u e ,   " , " )  
 	         I f   N o t   f D i s p l a y V e r s i o n   T h e n   f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ C 2 R P R O D U C T I D S   &   " A c t i v e \ c u l t u r e " ,   " x - n o n e " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
 	         I f   N O T   E r r   =   0   T h e n  
 	                 E r r . C l e a r  
 	         E l s e  
 	                 F o r   E a c h   p r o d   i n   a r r P r o d u c t s  
 	                         L o g O n l y   " F o u n d   O f f i c e   C 2 R   p r o d u c t   i n   C o n f i g u r a t i o n :   "   &   p r o d  
 	                         '   u p d a t e   v e r s i o n   t r a c k i n g  
 	                         I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( p r o d ) )   T h e n  
 	                         	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   L C a s e ( p r o d )  
 	                         	 d i c I n s t a l l e d S k u . A d d   L C a s e ( p r o d ) ,   s D i s p l a y V e r s i o n  
 	                         E n d   I f  
 	                 N e x t   ' p r o d  
 	         E n d   I f  
 	 E n d   I f  
  
 	 L o g O n l y   " C h e c k   f o r   O 1 6   C 2 R   p r o d u c t s   ( Q R 6 ) "  
 	 '   C h e c k   O 1 6   C o n f i g u r a t i o n   k e y  
         I f   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 6 C 2 R C O N F I G U R A T I O N ,   " P r o d u c t R e l e a s e I d s " ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
                 a r r P r o d u c t s   =   S p l i t ( s V a l u e ,   " , " )  
                 I f   N o t   f D i s p l a y V e r s i o n   T h e n   f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   R E G _ O 1 6 C 2 R P R O D U C T I D S   &   " c u l t u r e " ,   " x - n o n e " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
                 I f   N O T   E r r   =   0   T h e n  
                         E r r . C l e a r  
                 E l s e  
                         F o r   E a c h   p r o d   i n   a r r P r o d u c t s  
                                 L o g O n l y   " F o u n d   O 1 6   ( Q R 6 )   C 2 R   p r o d u c t   i n   C o n f i g u r a t i o n :   "   &   p r o d  
                                 '   u p d a t e   p r o d u c t   d i c t i o n a r y  
                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( p r o d ) )   T h e n  
                                 	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   p r o d  
                                 	 d i c I n s t a l l e d S k u . A d d   L C a s e ( p r o d ) ,   s D i s p l a y V e r s i o n  
                                 E n d   I f  
                         N e x t   ' p r o d  
                 E n d   I f  
         E n d   I f  
  
         L o g O n l y   " C h e c k   A R P   f o r   O f f i c e   C 2 R   p r o d u c t s "  
         '   A R P  
         R e g E n u m K e y   H K L M ,   R E G _ A R P ,   a r r K e y s  
         I f   I s A r r a y ( a r r K e y s )   T h e n  
                 F o r   E a c h   A r p I t e m   i n   a r r K e y s  
                         '   f i l t e r   o n   O f f i c e   C 2 R   p r o d u c t s  
                         s C u r K e y   =   R E G _ A R P   &   A r p I t e m   &   " \ "  
                         f U n i n s t a l l S t r i n g   =   R e g R e a d V a l u e ( H K L M ,   s C u r K e y ,   " U n i n s t a l l S t r i n g " ,   s V a l u e ,   " R E G _ S Z " )  
                         I f   ( f U n i n s t a l l S t r i n g   A n d (   ( I n S t r ( U C a s e ( s V a l u e ) ,   U C a s e ( " M i c r o s o f t   O f f i c e   1 " ) )   >   0 )   O r   ( I n S t r ( U C a s e ( s V a l u e ) ,   U C a s e ( " O f f i c e C l i c k T o R u n . e x e " ) )   >   0 )   ) )   T h e n  
                                 ' g e t   V e r s i o n  
                                 f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   s C u r K e y ,   " D i s p l a y V e r s i o n " ,   s D i s p l a y V e r s i o n ,   " R E G _ S Z " )  
                                 ' e x t r a c t   t h e   p r o d u c t r e l e a s e i d  
                                 s V a l u e   =   T r i m ( s V a l u e )  
                                 p r o d   =   T r i m ( M i d ( s V a l u e ,   I n S t r R e v ( s V a l u e ,   "   " ) ) )  
                                 p r o d   =   R e p l a c e ( p r o d ,   " p r o d u c t s t o r e m o v e = " ,   " " )  
                                 I f   I n S t r ( p r o d ,   " _ " )   >   0   T h e n  
                                         p r o d   =   L e f t ( p r o d ,   I n S t r ( p r o d ,   " _ " )   -   1 )  
                                 E n d   I f  
                                 I f   I n S t r ( p r o d ,   " . 1 " )   >   0   T h e n  
                                         p r o d   =   L e f t ( p r o d ,   I n S t r ( p r o d ,   " . 1 " )   -   1 )  
                                 E n d   I f  
                                 L o g O n l y   " F o u n d   C 2 R   p r o d u c t   i n   A R P :   "   &   p r o d  
                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( p r o d ) )   T h e n  
                                 	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y :   "   &   p r o d  
                                 	 d i c I n s t a l l e d S k u . A d d   L C a s e ( p r o d ) ,   s D i s p l a y V e r s i o n  
                                 E n d   I f  
                                 '   c a t e g o r i z e   t h e   S K U   a s   C 2 R  
                                 I f   N O T   d i c C 2 R S u i t e . E x i s t s ( A r p I t e m )   T h e n   d i c C 2 R S u i t e . A d d   A r p I t e m ,   p r o d   &   "   -   "   &   s D i s p l a y V e r s i o n    
                         E l s e  
                          
 	                         ' L e g a c y   l o g i c   k e e p   f o r   c o m p a t   r e a s o n s  
 	                         s V a l u e   =   " "  
 	                         s D i s p l a y V e r s i o n   =   " "  
 	                         f S y s t e m C o m p o n e n t 0   =   N O T   ( R e g R e a d V a l u e ( H K L M ,   s C u r K e y ,   " S y s t e m C o m p o n e n t " ,   s V a l u e ,   " R E G _ D W O R D " )   A N D   ( s V a l u e   =   " 1 " ) )  
 	                         f D i s p l a y V e r s i o n   =   R e g R e a d V a l u e ( H K L M ,   s C u r K e y ,   " D i s p l a y V e r s i o n " ,   s V a l u e ,   " R E G _ S Z " )  
 	                         I f   f D i s p l a y V e r s i o n   T h e n  
 	                                 s D i s p l a y V e r s i o n   =   s V a l u e  
 	                                 I f   L e n ( s V a l u e )   >   1   T h e n  
 	                                 	 O n   E r r o r   R e s u m e   N e x t  
 	                                         f D i s p l a y V e r s i o n   =   ( C I n t ( L e f t ( s V a l u e ,   2 ) )   >   1 4 )  
 	                                         I f   N o t   E r r   < >   0   T h e n   E r r . C l e a r  
 	                                 E l s e  
 	                                         f D i s p l a y V e r s i o n   =   F a l s e  
 	                                 E n d   I f  
 	                         E n d   I f  
 	                         f U n i n s t a l l S t r i n g   =   R e g R e a d V a l u e ( H K L M ,   s C u r K e y ,   " U n i n s t a l l S t r i n g " ,   s U n i n s t a l l S t r i n g ,   " R E G _ S Z " )  
 	                          
 	                         '   f i l t e r   o n   C 2 R   c o n f i g u r a t i o n   S K U  
 	                         I f   ( f U n i n s t a l l S t r i n g   A n d (   ( I n S t r ( U C a s e ( s U n i n s t a l l S t r i n g ) ,   U C a s e ( " M i c r o s o f t   O f f i c e   1 " ) )   >   0 )   O r   ( I n S t r ( U C a s e ( s U n i n s t a l l S t r i n g ) ,   U C a s e ( " O f f i c e C l i c k T o R u n . e x e " ) )   >   0 )   ) )   T h e n  
 	                                 '   E x t r a c t   t h e   P r o d u c t R e l e a s e I D  
 	                                 I f   I n S t r ( s U n i n s t a l l S t r i n g ,   " p r o d u c t s t o r e m o v e = " )   >   0   T h e n  
 	 	                                 s C o n f i g N a m e   =   T r i m ( M i d ( s V a l u e ,   I n S t r R e v ( s U n i n s t a l l S t r i n g ,   "   " ) ) )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " p r o d u c t s t o r e m o v e = " ,   " " )  
 	 	                                 I f   I n S t r ( p r o d ,   " _ " )   >   0   T h e n  
 	 	                                         s C o n f i g N a m e   =   L e f t ( s C o n f i g N a m e ,   I n S t r ( s C o n f i g N a m e ,   " _ " )   -   1 )  
 	 	                                 E n d   I f  
 	                                 E l s e  
 	 	                                 i L e f t   =   I n S t r ( A r p I t e m ,   "   -   " )   +   2  
 	 	                                 i R i g h t   =   I n S t r ( i L e f t ,   A r p I t e m ,   "   -   " )   -   1  
 	 	                                 I f   i R i g h t   >   0   T h e n  
 	 	                                         s C o n f i g N a m e   =   T r i m ( M i d ( A r p I t e m ,   i L e f t ,   ( i R i g h t   -   i L e f t ) ) )  
 	 	                                         s C u l t u r e   =   M i d ( A r p I t e m ,   i R i g h t   +   3 )  
 	 	                                 E l s e  
 	 	                                         s C o n f i g N a m e   =   T r i m ( L e f t ( A r p I t e m ,   i L e f t   -   3 ) )  
 	 	                                         s C u l t u r e   =   M i d ( A r p I t e m ,   i L e f t )  
 	 	                                 E n d   I f  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " M i c r o s o f t " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " O f f i c e " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " P r o f e s s i o n a l " ,   " P r o " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " S t a n d a r d " ,   " S t d " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " ( T e c h n i c a l   P r e v i e w ) " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " 1 5 " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " 1 6 " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " 2 0 1 3 " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " 2 0 1 6 " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   "   " ,   " " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " P r o j e c t " ,   " P r j " )  
 	 	                                 s C o n f i g N a m e   =   R e p l a c e ( s C o n f i g N a m e ,   " V i s i o " ,   " V i s " )  
 	                                 E n d   I f  
 	                                 I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( s C o n f i g N a m e ) )   T h e n  
 	                                 	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y   ( A R P   L e g a c y ) :   "   &   s C o n f i g N a m e  
 	                                 	 d i c I n s t a l l e d S k u . A d d   L C a s e ( s C o n f i g N a m e ) ,   s D i s p l a y V e r s i o n  
 	                                 E n d   I f  
 	                                 '   c a t e g o r i z e   t h e   S K U   a s   C 2 R  
 	                                 I f   N O T   d i c C 2 R S u i t e . E x i s t s ( A r p I t e m )   T h e n   d i c C 2 R S u i t e . A d d   A r p I t e m ,   s C o n f i g N a m e   &   "   -   "   &   s D i s p l a y V e r s i o n    
 	                         E l s e I f   ( f S y s t e m C o m p o n e n t 0   A N D   f D i s p l a y V e r s i o n   A N D   ( I n S t r ( U C a s e ( A r p I t e m ) ,   U C a s e ( " O F F I C E 1 5 . " ) )   >   0   O r   I n S t r ( U C a s e ( A r p I t e m ) ,   U C a s e ( " O F F I C E 1 6 . " ) )   >   0 ) )   T h e n  
 	                                 '   c l a s s i c   . m s i   i n s t a l l   S K U  
 	                                 i L e f t   =   I n S t r ( A r p I t e m ,   " . " )   +   1  
 	                                 i R i g h t   =   I n S t r ( i L e f t ,   A r p I t e m ,   " - " )   -   1  
 	                                 s C o n f i g N a m e   =   M i d ( A r p I t e m ,   i L e f t )  
 	                                 s C u l t u r e   =   " "  
 	                                 I f   N O T   d i c K e e p S k u . E x i s t s ( A r p I t e m )   T h e n   d i c K e e p S k u . A d d   A r p I t e m ,   s C o n f i g N a m e   &   "   -   "   &   s D i s p l a y V e r s i o n  
 	                         E n d   I f  
 	                          
 	                         '   O t h e r   p r o d u c t s  
 	                         I f   I n S c o p e ( A r p I t e m )   T h e n  
 	                                 S e l e c t   C a s e   M i d ( A r p I t e m , 1 1 , 4 )  
 	                                 '   0 0 7 E   =   L i c e n s i n g  
 	                                 '   0 0 8 C   =   E x t e n s i b i l i t y   C o m p o n e n t s  
 	                                 C a s e   " 0 0 7 E " ,   " 0 0 8 F " ,   " 0 0 8 C "  
 	                                         s C o n f i g N a m e   =   " H a b a n e r o "  
 	                                         R e g R e a d V a l u e   H K L M ,   s C u r K e y ,   " D i s p l a y N a m e " ,   s C o n f i g N a m e ,   " R E G _ S Z "  
 	                                         I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( A r p I t e m ) )   T h e n  
 	                                         	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y   ( A R P   L e g a c y   o t h e r ) :   "   &   A r p I t e m  
 	                                         	 d i c I n s t a l l e d S k u . A d d   L C a s e ( A r p I t e m ) ,   s D i s p l a y V e r s i o n  
 	                                         E n d   I f  
 	                                         I f   N O T   d i c C 2 R S u i t e . E x i s t s ( A r p I t e m )   T h e n   d i c C 2 R S u i t e . A d d   A r p I t e m ,   s C o n f i g N a m e   &   "   -   "   &   s D i s p l a y V e r s i o n  
 	                                 C a s e   " 2 4 E 1 " ,   " 2 3 7 A "  
 	                                         s C o n f i g N a m e   =   " M S O I D L O G I N "  
 	                                         I f   N O T   d i c I n s t a l l e d S k u . E x i s t s ( L C a s e ( A r p I t e m ) )   T h e n  
 	                                         	 L o g O n l y   " a d d i n g   n e w   p r o d u c t   t o   d i c t i o n a r y   ( A R P   L e g a c y   o t h e r ) :   "   &   A r p I t e m  
 	                                         	 d i c I n s t a l l e d S k u . A d d   L C a s e ( A r p I t e m ) ,   s D i s p l a y V e r s i o n  
 	                                         E n d   I f  
 	                                         I f   N O T   d i c C 2 R S u i t e . E x i s t s ( A r p I t e m )   T h e n   d i c C 2 R S u i t e . A d d   A r p I t e m ,   s C o n f i g N a m e   &   "   -   "   &   s D i s p l a y V e r s i o n  
 	                                 C a s e   E l s e  
 	                                         '   n o t   i n   s c o p e   f o r   c 2 r   r e m o v a l !  
 	                                         I f   N O T   d i c K e e p S k u . E x i s t s ( A r p I t e m )   T h e n   d i c K e e p S k u . A d d   A r p I t e m ,   A r p I t e m  
 	                                 E n d   S e l e c t  
 	                         E n d   I f   ' I n S c o p e      
 	                         '   E n d   l e g a c y   l o g i c  
 	                          
                         E n d   I f  
                 N e x t   ' A r p I t e m  
         E n d   I f  
          
 E n d   S u b   ' F i n d I n s t a l l e d O P r o d u c t s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       E n s u r e V a l i d W I M e t a d a t a  
 '  
 '       E n s u r e s   t h a t   o n l y   v a l i d   m e t a d a t a   e n t r i e s   e x i s t   t o   a v o i d   A P I   f a i l u r e s .  
 '       I n v a l i d   e n t r i e s   w i l l   b e   r e m o v e d  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   E n s u r e V a l i d W I M e t a d a t a ( h D e f K e y ,   s K e y ,   i V a l i d L e n g t h )  
         D i m   a r r K e y s  
         D i m   S u b K e y  
  
         I f   L e n ( s K e y )   >   1   T h e n  
                 I f   R i g h t ( s K e y ,   1 )   =   " \ "   T h e n   s K e y   =   L e f t ( s K e y ,   L e n ( s K e y )   -   1 )  
         E n d   I f  
  
         I f   R e g E n u m K e y ( h D e f K e y ,   s K e y ,   a r r K e y s )   T h e n  
                 F o r   E a c h   S u b K e y   i n   a r r K e y s  
                         I f   N O T   L e n ( S u b K e y )   =   i V a l i d L e n g t h   T h e n  
                                 R e g D e l e t e K e y   h D e f K e y ,   s K e y   &   " \ "   &   S u b K e y   &   " \ "  
                         E n d   I f  
                 N e x t   ' S u b K e y  
         E n d   I f  
 E n d   S u b   ' E n s u r e V a l i d W I M e t a d a t a  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C l e a n O S P P  
 '  
 '       C l e a n   o u t   l i c e n s e s   f r o m   t h e   O f f i c e   S o f t w a r e   P r o t e c t i o n   P l a t f o r m    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C l e a n O S P P  
         D i m   o P r o d u c t I n s t a n c e s ,   p i  
         D i m   s C l e a n O S P P ,   s C m d ,   s R e t V a l  
  
         C O N S T   O f f i c e A p p I d   =   " 0 f f 1 c e 1 5 - a 9 8 9 - 4 7 9 d - a f 4 6 - f 2 7 5 c 6 3 7 0 6 6 3 "     ' O f f i c e   2 0 1 3  
  
         s C l e a n O S P P   =   " x 6 4 \ C l e a n O S P P . e x e "  
         I f   N o t   f 6 4   T h e n   s C l e a n O S P P   =   " x 8 6 \ C l e a n O S P P . e x e "  
         I f   o F s o . F i l e E x i s t s ( s S c r i p t D i r   &   s C l e a n O S P P )   T h e n  
                 s C m d   =   s S c r i p t D i r   &   s C l e a n O S P P  
                 L o g   "       R u n n i n g :   "   &   s C m d  
                 O n   E r r o r   R e s u m e   N e x t  
                 s R e t V a l   =   o W S h e l l . R u n ( s C m d ,   0 ,   T r u e )  
                 L o g   "       R e t u r n   v a l u e :   "   &   s R e t V a l  
                 O n   E r r o r   G o t o   0  
                 E x i t   S u b  
         E n d   I f  
          
         O n   E r r o r   R e s u m e   N e x t  
         I f   N O T   ( d i c C 2 R S u i t e . C o u n t   >   0   O R   d i c K e e p S k u . C o u n t   >   0 )   T h e n  
                 L o g   " S k i p p i n g   C l e a n O S P P "  
                 E x i t   S u b  
         E n d   I f  
          
         '   I n i t i a l i z e   t h e   s o f t w a r e   p r o t e c t i o n   p l a t f o r m   o b j e c t   w i t h   a   f i l t e r   o n   O f f i c e   2 0 1 3   p r o d u c t s  
         I f   i V e r s i o n N T   >   6 0 1   T h e n  
                 S e t   o P r o d u c t I n s t a n c e s   =   o W m i L o c a l . E x e c Q u e r y ( " S E L E C T   I D ,   A p p l i c a t i o n I d ,   P a r t i a l P r o d u c t K e y ,   N a m e ,   P r o d u c t K e y I D   F R O M   S o f t w a r e L i c e n s i n g P r o d u c t   W H E R E   A p p l i c a t i o n I d   =   ' "   &   O f f i c e A p p I d   &   " '   "   &   " A N D   P a r t i a l P r o d u c t K e y   < >   N U L L " )  
         E l s e  
                 S e t   o P r o d u c t I n s t a n c e s   =   o W m i L o c a l . E x e c Q u e r y ( " S E L E C T   I D ,   A p p l i c a t i o n I d ,   P a r t i a l P r o d u c t K e y ,   N a m e ,   P r o d u c t K e y I D   F R O M   O f f i c e S o f t w a r e P r o t e c t i o n P r o d u c t   W H E R E   A p p l i c a t i o n I d   =   ' "   &   O f f i c e A p p I d   &   " '   "   &   " A N D   P a r t i a l P r o d u c t K e y   < >   N U L L " )  
         E n d   I f  
  
         '   R e m o v e   a l l   l i c e n s e s  
         F o r   E a c h   p i   i n   o P r o d u c t I n s t a n c e s  
                 I f   N O T   I s N u l l ( p i )   T h e n  
                         p i . U n i n s t a l l P r o d u c t K e y (   p i . P r o d u c t K e y I D )  
                 E n d   I f  
         N e x t   ' p i  
  
  
 E n d   S u b   ' C l e a n O S P P  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l S c h t a s k s  
 '  
 '       D e l e t e   k n o w   s c h e d u l e d   t a s k s .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   D e l S c h t a s k s   ( )  
         D i m   s C m d  
  
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   E x i t   S u b  
  
         L o g H 2   " R e m o v i n g   s c h e d u l e d   t a s k s "    
  
         L o g O n l y   " F F _ I N T E G R A T E D s t r e a m S c h e d u l e "  
         o W S h e l l . R u n   " S C H T A S K S   / D e l e t e   / T N   F F _ I N T E G R A T E D s t r e a m S c h e d u l e   / F " ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " F F _ I N T E G R A T E D U P D A T E D E T E C T I O N "  
         o W S h e l l . R u n   " S C H T A S K S   / D e l e t e   / T N   F F _ I N T E G R A T E D U P D A T E D E T E C T I O N   / F " ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " C 2 R A p p V L o g g i n g S t a r t "  
         o W S h e l l . R u n   " S C H T A S K S   / D e l e t e   / T N   C 2 R A p p V L o g g i n g S t a r t   / F " ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e   1 5   S u b s c r i p t i o n   H e a r t b e a t "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " O f f i c e   1 5   S u b s c r i p t i o n   H e a r t b e a t "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " M i c r o s o f t   O f f i c e   1 5   S y n c   M a i n t e n a n c e "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " M i c r o s o f t   O f f i c e   1 5   S y n c   M a i n t e n a n c e   f o r   { d 0 6 8 b 5 5 5 - 9 7 0 0 - 4 0 b 8 - 9 9 2 c - f 8 6 6 2 8 7 b 0 6 c 1 } "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e I n v e n t o r y A g e n t F a l l B a c k "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e I n v e n t o r y A g e n t F a l l B a c k "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e T e l e m e t r y A g e n t F a l l B a c k "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e T e l e m e t r y A g e n t F a l l B a c k "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e I n v e n t o r y A g e n t L o g O n "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e I n v e n t o r y A g e n t L o g O n "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
  
         L o g O n l y   " O f f i c e T e l e m e t r y A g e n t L o g O n "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e T e l e m e t r y A g e n t L o g O n "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
  
         L o g O n l y   " O f f i c e   B a c k g r o u n d   S t r e a m i n g "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " O f f i c e   B a c k g r o u n d   S t r e a m i n g "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e   A u t o m a t i c   U p d a t e s "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e   A u t o m a t i c   U p d a t e s "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e   C l i c k T o R u n   S e r v i c e   M o n i t o r "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " \ M i c r o s o f t \ O f f i c e \ O f f i c e   C l i c k T o R u n   S e r v i c e   M o n i t o r "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
         L o g O n l y   " O f f i c e   S u b s c r i p t i o n   M a i n t e n a n c e "  
         s C m d   =   " S C H T A S K S   / D e l e t e   / T N   "   &   C h r ( 3 4 )   &   " O f f i c e   S u b s c r i p t i o n   M a i n t e n a n c e "   &   C h r ( 3 4 )   &   "   / F "  
         o W S h e l l . R u n   s C m d ,   0 ,   F a l s e  
         w s c r i p t . s l e e p   5 0 0  
  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C l o s e O f f i c e A p p s  
 '  
 '       E n d   a l l   r u n n i n g   i n s t a n c e s   o f   a p p l i c a t i o n s   t h a t   w i l l   b e   r e m o v e d .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C l o s e O f f i c e A p p s  
         D i m   P r o c e s s e s ,   P r o c e s s ,   a p p ,   p r o p  
         D i m   s A p p N a m e ,   s O u t ,   s U s e r W a r n  
         D i m   f W a i t  
         D i m   i R e t  
          
         O n   E r r o r   R e s u m e   N e x t  
         f W a i t   =   F a l s e  
         i P r o c C l o s e C n t   =   i P r o c C l o s e C n t   +   1  
         I f   f R e r u n   T h e n   E x i t   S u b  
  
         I f   N O T   f U s e r C o n s e n t   T h e n  
                 '   d e t e c t   p r o c e s s e s   t o   a l l o w   a   u s e r   w a r n i n g  
                 s U s e r W a r n   =     " P l e a s e   s a v e   a l l   o p e n   d o c u m e n t s   a n d   c l o s e   a l l   O f f i c e ,   I E   a n d   W i n d o w s   E x p l o r e r   a p p l i c a t i o n s   b e f o r e   p r o c e e d i n g . "   &   v b C r L f   &   _  
                                         " W h e n   y o u   c l i c k   O K   t h i s   r e m o v a l   p r o c e s s   w i l l   t e r m i n a t e   a l l   r u n n i n g   O f f i c e ,   I E   a n d   W i n d o w s   E x p l o r e r   p r o c e s s e s   a n d   a p p l i c a t i o n s . "   &   v b C r L f   &   v b C r L f   &   _  
                                         " C l i c k    C a n c e l    t o   t o   e n d   t h i s   r e m o v a l   n o w . "  
                 F o r   E a c h   a p p   i n   d i c A p p s . K e y s  
                         s A p p N a m e   =   R e p l a c e ( a p p ,   " . " ,   " % . " )  
                         S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W h e r e   N a m e   l i k e   ' "   &   s A p p N a m e   &   " ' " )  
                         F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
                                 I f   N O T   I n S t r ( s U s e r W a r n ,   P r o c e s s . N a m e )   >   0   T h e n   s U s e r W a r n   =   s U s e r W a r n   &   v b C r L f   &   "   -   "   &   P r o c e s s . N a m e  
                         N e x t   ' P r o c e s s  
                 N e x t   ' a p p  
                 S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s " )  
                 F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
                         F o r   E a c h   p r o p   i n   P r o c e s s . P r o p e r t i e s _  
                                 I f   p r o p . N a m e   =   " E x e c u t a b l e P a t h "   T h e n    
                                         I f   I s C 2 R ( p r o p . V a l u e )   T h e n   s U s e r W a r n   =   s U s e r W a r n   &   v b C r L f   &   "   -   "   &   P r o c e s s . N a m e  
                                 E n d   I f   ' E x c e c u t a b l e P a t h  
                         N e x t   ' p r o p  
                 N e x t   ' P r o c e s s  
                 I f   ( I n S t r ( s U s e r W a r n ,   "   -   " )   >   0   A N D   N O T   f Q u i e t )   T h e n  
                         i R e t   =   M s g B o x ( s U s e r W a r n ,   4 9 ,   " S a v e   y o u r   u n s a v e d   w o r k   n o w ! " )  
                         I f   i R e t   =   2   T h e n    
                                 S e t E r r o r   E R R O R _ U S E R C A N C E L  
                                 E x i t S c r i p t  
                         E l s e  
                                 f U s e r C o n s e n t   =   T r u e  
                         E n d   I f  
                 E n d   I f  
         E n d   I f   ' f U s e r C o n s e n t  
  
         '   e n d   k n o w n   p r o c e s s e s   f i r s t  
         F o r   E a c h   a p p   i n   d i c A p p s . K e y s  
                 s A p p N a m e   =   R e p l a c e ( a p p ,   " . " ,   " % . " )  
                 S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W h e r e   N a m e   l i k e   ' "   &   s A p p N a m e   &   " ' " )  
                 F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
                         s O u t   =   " E n d   p r o c e s s   ' "   &   P r o c e s s . N a m e  
                         i R e t   =   P r o c e s s . T e r m i n a t e ( )  
                         C h e c k E r r o r   " C l o s e O f f i c e A p p s :   "   &   " P r o c e s s . N a m e "  
                         L o g   s O u t   &   " '   r e t u r n e d :   "   &   i R e t  
                         f W a i t   =   T r u e  
                 N e x t   ' P r o c e s s  
         N e x t   ' a p p  
  
         '   e n d   r u n n i n g   a p p l i c a t i o n s  
         S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s " )  
         F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
                 F o r   E a c h   p r o p   i n   P r o c e s s . P r o p e r t i e s _  
                         I f   p r o p . N a m e   =   " E x e c u t a b l e P a t h "   T h e n    
                                 I f   I s C 2 R ( p r o p . V a l u e )   T h e n  
                                         s O u t   =   " E n d   p r o c e s s   ' "   &   P r o c e s s . N a m e  
                                         i R e t   =   P r o c e s s . T e r m i n a t e ( )  
                                         C h e c k E r r o r   " C l o s e O f f i c e A p p s :   "   &   " P r o c e s s . N a m e "  
                                         L o g   s O u t   &   " '   r e t u r n e d :   "   &   i R e t  
                                         f W a i t   =   T r u e  
                                 E n d   I f    
                         E n d   I f   ' E x c e c u t a b l e P a t h  
                 N e x t   ' p r o p  
         N e x t   ' P r o c e s s  
         I f   f W a i t   T h e n   w s c r i p t . s l e e p   5 0 0 0  
 E n d   S u b   ' C l o s e O f f i c e A p p s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       U n i n s t a l l  
 '  
 '       I d e n t i f y   a n d   i n v o k e   d e f a u l t   u n i n s t a l l   c o m m a n d   f o r   a   r e g u l a r   u n i n s t a l l .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   U n i n s t a l l  
         D i m   O s e S e r v i c e ,   s r v c  
         D i m   h D e f K e y ,   s S u b K e y N a m e ,   s V a l u e ,   N a m e ,   a r r N a m e s ,   a r r T y p e s  
         D i m   s k u ,   p r o d ,   s U n i n s t a l l C m d ,   s R e t u r n ,   s M s i P r o p ,   s C m d  
         D i m   s P k g F l d ,   s P k g G u i d  
         D i m   i  
  
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   E x i t   S u b  
  
         '   c h e c k   i f   O S E   s e r v i c e   i s   * i n s t a l l e d ,   * n o t   d i s a b l e d ,   * r u n n i n g   u n d e r   S y s t e m   c o n t e x t .  
         L o g H 2   " C h e c k i n g   s t a t e   o f   O S E   s e r v i c e "  
         S e t   O s e S e r v i c e   =   o W m i L o c a l . E x e c q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ S e r v i c e   W h e r e   N a m e   l i k e   ' o s e % ' " )  
         F o r   E a c h   s r v c   i n   O s e S e r v i c e  
                 I f   ( s r v c . S t a r t M o d e   =   " D i s a b l e d " )   A N D   ( N o t   s r v c . C h a n g e S t a r t M o d e ( " M a n u a l " )   =   0 )   T h e n   _  
                         L o g   " C o n f l i c t   d e t e c t e d :   O S E   s e r v i c e   i s   d i s a b l e d "  
                 I f   ( N o t   s r v c . S t a r t N a m e   =   " L o c a l S y s t e m " )   A N D   ( s r v c . C h a n g e (   ,   ,   ,   ,   ,   ,   " L o c a l S y s t e m " ,   " " ) )   T h e n   _  
                         L o g   " C o n f l i c t   d e t e c t e d :   O S E   s e r v i c e   n o t   r u n n i n g   a s   L o c a l S y s t e m "  
         N e x t   ' s r v c  
  
         I f   N O T   d i c C 2 R S u i t e . C o u n t   >   0   T h e n  
                 L o g   " N o   u n i n s t a l l a b l e   C 2 R   i t e m s   r e g i s t e r e d   i n   U n i n s t a l l "  
         E n d   I f  
  
         '   r e m o v e   t h e   p u b l i s h e d   c o m p o n e n t   r e g i s t r a t i o n   f o r   C 2 R   p a c k a g e s  
         L o g H 2   " R e m o v i n g   p u b l i s h e d   c o m p o n e n t   r e g i s t r a t i o n   f o r   C 2 R   p a c k a g e s "  
         '   d e l e t e   t h e   m a n i f e s t   f i l e s  
         F o r   i   =   1   T o   4  
         	 S e l e c t   C a s e   i  
         	 C a s e   1  
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s P k g F l d ,   " R E G _ S Z "    
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s P k g G u i d ,   " R E G _ S Z "  
 	         C a s e   2  
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s P k g F l d ,   " R E G _ S Z "    
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s P k g G u i d ,   " R E G _ S Z "  
 	         C a s e   3  
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n " ,   " P a c k a g e F o l d e r " ,   s P k g F l d ,   " R E G _ S Z "    
 	         	 R e g R e a d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n " ,   " P a c k a g e G U I D " ,   s P k g G u i d ,   " R E G _ S Z "  
 	         C a s e   4  
 	         	 s P k g F l d   =   s P a c k a g e F o l d e r  
 	         	 s P k g G u i d   =   s P a c k a g e G u i d  
 	         E n d   S e l e c t  
 	         I f   o F s o . F o l d e r E x i s t s ( s V a l u e   &   " \ r o o t \ I n t e g r a t i o n " )   T h e n  
 	                 s C m d   =   " c m d . e x e   / c   d e l   "   &   c h r ( 3 4 )   &   s P k g F l d   &   " \ r o o t \ I n t e g r a t i o n \ C 2 R M a n i f e s t * . x m l "   &   c h r ( 3 4 )  
 	                 L o g   "       R u n n i n g :   "   &   s C m d  
 	                 s R e t u r n   =   o W S h e l l . R u n   ( s C m d ,   0 ,   T r u e )  
 	                 L o g   "       R e t u r n   v a l u e :   "   &   s R e t u r n  
 	                 I f   o F s o . F i l e E x i s t s ( s P k g F l d   &   " \ r o o t \ I n t e g r a t i o n \ i n t e g r a t o r . e x e " )   T h e n  
 	                         s C m d   =   c h r ( 3 4 )   &   s P k g F l d   &   " \ r o o t \ I n t e g r a t i o n \ i n t e g r a t o r . e x e "   &   c h r ( 3 4 )   &   "   / U     / E x t e n s i o n   P a c k a g e R o o t = "   &   c h r ( 3 4 )   &   s P k g F l d   &   " \ r o o t "   &   c h r ( 3 4 )   &   "   P a c k a g e G U I D = "   &   s P k g G u i d  
 	                         L o g   "       R u n n i n g :   "   &   s C m d  
 	                         s R e t u r n   =   o W S h e l l . R u n   ( s C m d ,   0 ,   T r u e )  
 	                         L o g   "       R e t u r n   v a l u e :   "   &   s R e t u r n  
 	                         s C m d   =   c h r ( 3 4 )   &   s P k g F l d   &   " \ r o o t \ I n t e g r a t i o n \ i n t e g r a t o r . e x e "   &   c h r ( 3 4 )   &   "   / U "  
 	                         L o g   "       R u n n i n g :   "   &   s C m d  
 	                         s R e t u r n   =   o W S h e l l . R u n   ( s C m d ,   0 ,   T r u e )  
 	                         L o g   "       R e t u r n   v a l u e :   "   &   s R e t u r n  
 	                 E n d   I f  
 	                 I f   o F s o . F i l e E x i s t s ( s P r o g r a m D a t a   &   " \ M i c r o s o f t \ C l i c k T o R u n \ { "   &   s P k g G u i d   &   " } \ i n t e g r a t o r . e x e " )   T h e n  
 	                         s C m d   =   c h r ( 3 4 )   &   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ C l i c k T o R u n \ { "   &   s P k g G u i d   &   " } \ i n t e g r a t o r . e x e "   &   c h r ( 3 4 )   &   "   / U     / E x t e n s i o n   P a c k a g e R o o t = "   &   c h r ( 3 4 )   &   s P k g F l d   &   " \ r o o t "   &   c h r ( 3 4 )   &   "   P a c k a g e G U I D = "   &   s P k g G u i d  
 	                         L o g   "       R u n n i n g :   "   &   s C m d  
 	                         s R e t u r n   =   o W S h e l l . R u n   ( s C m d ,   0 ,   T r u e )  
 	                         L o g   "       R e t u r n   v a l u e :   "   &   s R e t u r n  
 	                 E n d   I f  
 	         E n d   I f  
         N e x t   ' i  
  
         '   d e l e t e   p o t e n t i a l   b l o c k i n g   r e g i s t r y   k e y s   f o r   m s i e x e c   b a s e d   t a s k s  
         L o g H 2   " R e m o v i n g   C 2 R   a n d   A p p - V   r e g i s t r y   d a t a "  
         F o r   E a c h   s k u   i n   d i c C 2 R S u i t e . K e y s  
                 '   r e m o v e   t h e   A R P   e n t r y  
                 R e g D e l e t e K e y   H K L M ,   R E G _ A R P   &   s k u  
         N e x t   ' s k u  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n "  
          
         '   A p p V   k e y s  
         h D e f K e y   =   H K C U  
         s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ A p p V \ I S V "  
         D o  
                 I f   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s )   T h e n  
                         F o r   E a c h   N a m e   i n   a r r N a m e s  
                                 I f   I s C 2 R ( N a m e )   T h e n   R e g D e l e t e V a l u e   h D e f K e y ,   s S u b K e y N a m e ,   N a m e ,   F a l s e  
                         N e x t   ' N a m e  
                 E n d   I f   ' R e g E n u m V a l u e s  
                 I f   h D e f K e y   =   H K L M   T h e n   E x i t   D o  
                 h D e f K e y   =   H K L M  
         L o o p  
  
         '   m s i e x e c   b a s e d   u n i n s t a l l  
         s M s i P r o p   =   "   R E B O O T = R e a l l y S u p p r e s s   N O R E M O V E S P A W N = T r u e "  
         L o g H 2   " D e t e c t   M s i   b a s e d   p r o d u c t s "  
         F o r   E a c h   p r o d   i n   o M s i . P r o d u c t s  
                 I f   C h e c k D e l e t e ( p r o d )   T h e n  
                         L o g   " C a l l i n g   m s i e x e c . e x e   t o   r e m o v e   "   &   p r o d    
                         s U n i n s t a l l C m d   =   " m s i e x e c . e x e   / x "   &   p r o d   &   s M s i P r o p  
                         I f   f Q u i e t   T h e n    
                                 s U n i n s t a l l C m d   =   s U n i n s t a l l C m d   &   "   / q "  
                         E l s e  
                                 s U n i n s t a l l C m d   =   s U n i n s t a l l C m d   &   "   / q b - ! "  
                         E n d   I f  
                         s U n i n s t a l l C m d   =   s U n i n s t a l l C m d   &   "   / l * v   "   &   c h r ( 3 4 )   &   s L o g D i r   &   " \ U n i n s t a l l _ "   &   p r o d   &   " . l o g "   &   c h r ( 3 4 )  
                         C l o s e O f f i c e A p p s  
                         L o g O n l y   " C a l l i n g   m s i e x e c   w i t h   ' "   &   s U n i n s t a l l C m d   &   " ' "  
                         s R e t u r n   =   o W S h e l l . R u n ( s U n i n s t a l l C m d ,   0 ,   T r u e )  
                         L o g   " m s i e x e c   r e t u r n e d :   "   &   S e t u p R e t V a l ( s R e t u r n )   &   "   ( "   &   s R e t u r n   &   " ) "   &   v b C r L f  
                         f R e b o o t R e q u i r e d   =   f R e b o o t R e q u i r e d   O R   ( s R e t u r n   =   " 3 0 1 0 " )  
                         I f   f R e b o o t R e q u i r e d   T h e n   S e t E r r o r   E R R O R _ R E B O O T _ R E Q U I R E D  
                         S e l e c t   C a s e   C I n t ( s R e t u r n )  
                         C a s e   E R R O R _ S U C C E S S , E R R O R _ S U C C E S S _ C O N F I G _ C O M P L E T E , E R R O R _ S U C C E S S _ R E B O O T _ R E Q U I R E D  
                                 ' s u c c e s s   n o   a c t i o n   r e q u i r e d  
                         C a s e   E l s e  
                                 S e t E r r o r   E R R O R _ S T A G E 1  
                         E n d   S e l e c t  
                 E l s e  
                 	 L o g O n l y   " S k i p p i n g   o u t   o f   s c o p e   p r o d u c t :   "   &   p r o d  
                 E n d   I f   ' C h e c k D e l e t e  
         N e x t   ' P r o d u c t  
         o W S h e l l . R u n   " c m d . e x e   / c   n e t   s t o p   m s i s e r v e r " ,   0 ,   F a l s e  
 E n d   S u b   ' U n i n s t a l l  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g W i p e  
 '  
 '       R e m o v a l   o f   l e f t   b e h i n d   r e g i s t r y   d a t a    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e g w i p e  
         D i m   h D e f K e y ,   i t e m ,   n a m e ,   v a l u e ,   R e t V a l  
         D i m   s G u i d ,   s S u b K e y N a m e ,   s V a l u e ,   s C m d  
         D i m   i ,   i L o o p C n t  
         D i m   a r r K e y s ,   a r r N a m e s ,   a r r T y p e s ,   a r r T e s t N a m e s ,   a r r T e s t T y p e s  
         D i m   a r r M u l t i S z V a l u e s ,   a r r M u l t i S z N e w V a l u e s  
         D i m   f D e l R e g  
  
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   E x i t   S u b  
  
         L o g H 1   " R e g i s t r y   C l e a n U p "  
         C l o s e O f f i c e A p p s  
  
         '   N o t e :   A R P   e n t r i e s   h a v e   a l r e a d y   b e e n   c l e a r e d   i n   u n i n s t a l l   s t a g e  
  
         '   H K C U   R e g i s t r a t i o n  
         R e g D e l e t e K e y   H K C U ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ R e g i s t r a t i o n "  
         R e g D e l e t e K e y   H K C U ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ R e g i s t r a t i o n "  
         R e g D e l e t e K e y   H K C U ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ R e g i s t r a t i o n "  
  
          
         '   C 2 R   s p e c i f i c s  
         '   A p p V   k e y   " S O F T W A R E \ M i c r o s o f t \ A p p V "   h a s   a l r e a d y   b e e n   c l e a r e d   i n   u n i n s t a l l   s t a g e  
  
         '   V i r t u a l   I n s t a l l R o o t  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C o m m o n \ I n s t a l l R o o t \ V i r t u a l "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C o m m o n \ I n s t a l l R o o t \ V i r t u a l "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C o m m o n \ I n s t a l l R o o t \ V i r t u a l "  
  
         '   M a p i   r e g  
         I f   N O T   d i c K e e p S k u . C o u n t   >   0   T h e n   R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ C l a s s e s \ C L S I D \ { 2 0 2 7 F C 3 B - C F 9 D - 4 e c 7 - A 8 2 3 - 3 8 B A 3 0 8 6 2 5 C C } "  
          
         '   C 2 R   k e y s  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n S t o r e "  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 \ C l i c k T o R u n S t o r e "  
         R e g D e l e t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n "  
         R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ C l i c k T o R u n S t o r e "  
          
         '   O f f i c e   k e y   i n   H K L M  
         I f   N o t   d i c K e e p S k u . C o u n t   >   0   T h e n  
         	 ' d o u b l e   c a l l s   t o   e n s u r e   W o w 6 4 3 2   g e t s   c l e a r e d   o u t   a s   w e l l  
         	 R e g D e l e t e K e y   H K L M ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 "  
         	 R e g D e l e t e K e y   H K L M ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 "  
         	 R e g D e l e t e K e y   H K L M ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 "  
         	 R e g D e l e t e K e y   H K L M ,   " S o f t w a r e \ M i c r o s o f t \ O f f i c e \ 1 6 . 0 "  
         E n d   I f  
         C l e a r O f f i c e H K L M   " S O F T W A R E \ M i c r o s o f t \ O f f i c e "  
  
         '   R u n   k e y  
         s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n "  
         I f   R e g E n u m V a l u e s   ( H K L M ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s )   T h e n  
                 F o r   E a c h   n a m e   i n   a r r N a m e s  
                         I f   R e g R e a d V a l u e ( H K L M ,   s S u b K e y N a m e ,   n a m e ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
                                 I f   I s C 2 R ( s V a l u e )   T h e n   R e g D e l e t e V a l u e   H K L M ,   s S u b K e y N a m e ,   n a m e ,   F a l s e  
                         E n d   I f  
                 N e x t   ' i t e m  
         E n d   I f  
         R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n " ,   " L y n c 1 5 " ,   F a l s e  
         R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n " ,   " L y n c 1 6 " ,   F a l s e  
          
          
         I f   N O T   d i c K e e p S k u . C o u n t   >   0   T h e n    
                 '   P r o t o c o l   H a n d l e r s  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ C l a s s e s \ P r o t o c o l s \ H a n d l e r \ o s f "  
          
                 '   G r o o v e   S h e l l I c o n O v e r l a y I d e n t i f i e r s  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   1   ( E r r o r C o n f l i c t ) "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   2   ( S y n c I n P r o g r e s s ) "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   3   ( I n S y n c ) "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   1   ( E r r o r C o n f l i c t ) "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   2   ( S y n c I n P r o g r e s s ) "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ S h e l l I c o n O v e r l a y I d e n t i f i e r s \ M i c r o s o f t   S P F S   I c o n   O v e r l a y   3   ( I n S y n c ) "  
  
                 '   S h e l l   e x t e n s i o n s  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { B 2 8 A A 7 3 6 - 8 7 6 B - 4 6 D A - B 3 A 8 - 8 4 C 5 E 3 0 B A 4 9 2 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 8 B 0 2 D 6 5 9 - E B B B - 4 3 D 7 - 9 B B A - 5 2 C F 2 2 C 5 B 0 2 5 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 0 8 7 5 D C B 6 - C 6 8 6 - 4 2 4 3 - 9 4 3 2 - A D C C F 0 B 9 F 2 D 7 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 4 2 0 4 2 2 0 6 - 2 D 8 5 - 1 1 D 3 - 8 C F F - 0 0 5 0 0 4 8 3 8 5 9 7 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 9 9 3 B E 2 8 1 - 6 6 9 5 - 4 B A 5 - 8 A 2 A - 7 A A C B F A A B 6 9 E } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { C 4 1 6 6 2 B B - 1 F A 0 - 4 C E 0 - 8 D C 5 - 9 B 7 F 8 2 7 9 F F 9 7 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 5 0 6 F 4 6 6 8 - F 1 3 E - 4 A A 1 - B B 0 4 - B 4 3 2 0 3 A B 3 C C 0 } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { D 6 6 D C 7 8 C - 4 F 6 1 - 4 4 7 F - 9 4 2 B - 3 F B 6 9 8 0 1 1 8 C F } " ,   F a l s e  
                 R e g D e l e t e V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ S h e l l   E x t e n s i o n s \ A p p r o v e d \ " ,   " { 4 6 1 3 7 B 7 8 - 0 E C 3 - 4 2 6 D - 8 B 8 9 - F F 7 C 3 A 4 5 8 B 5 E } " ,   F a l s e  
          
                 '   B H O  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { 3 1 D 0 9 B A 0 - 1 2 F 5 - 4 C C E - B E 8 A - 2 9 2 3 E 7 6 6 0 5 D A } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { B 4 F 3 A 8 3 5 - 0 E 2 1 - 4 9 5 9 - B A 2 2 - 4 2 B 3 0 0 8 E 0 2 F F } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { D 0 4 9 8 E 0 A - 4 5 B 7 - 4 2 A E - A 9 A A - A B A 4 6 3 D B D 3 B F } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { 3 1 D 0 9 B A 0 - 1 2 F 5 - 4 C C E - B E 8 A - 2 9 2 3 E 7 6 6 0 5 D A } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { B 4 F 3 A 8 3 5 - 0 E 2 1 - 4 9 5 9 - B A 2 2 - 4 2 B 3 0 0 8 E 0 2 F F } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ W o w 6 4 3 2 N o d e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ B r o w s e r   H e l p e r   O b j e c t s \ { D 0 4 9 8 E 0 A - 4 5 B 7 - 4 2 A E - A 9 A A - A B A 4 6 3 D B D 3 B F } "  
          
                 '   O n e N o t e   N a m e s p a c e   E x t e n s i o n   f o r   D e s k t o p  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ D e s k t o p \ N a m e S p a c e \ { 0 8 7 5 D C B 6 - C 6 8 6 - 4 2 4 3 - 9 4 3 2 - A D C C F 0 B 9 F 2 D 7 } "  
          
                 '   W e b   S i t e s  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ D e s k t o p \ N a m e s p a c e \ { B 2 8 A A 7 3 6 - 8 7 6 B - 4 6 D A - B 3 A 8 - 8 4 C 5 E 3 0 B A 4 9 2 } "  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ N e t w o r k N e i g h b o r h o o d \ N a m e s p a c e \ { 4 6 1 3 7 B 7 8 - 0 E C 3 - 4 2 6 D - 8 B 8 9 - F F 7 C 3 A 4 5 8 B 5 E } "  
  
                 '   V o l u m e C a c h e s  
                 R e g D e l e t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ V o l u m e C a c h e s \ M i c r o s o f t   O f f i c e   T e m p   F i l e s "  
         E n d   I f   ' N O T   d i c K e e p S k u . C o u n t   >   0  
  
         '   A R P  
         '   N o t e :   c o n f i g u r a t i o n   e n t r i e s   h a v e   a l r e a d y   b e e n   r e m o v e d    
         '   a s   p a r t   o f   t h e   ' U n i n s t a l l '   s t a g e  
         I f   R e g E n u m K e y ( H K L M ,   R E G _ A R P ,   a r r K e y s )   T h e n  
                 F o r   E a c h   i t e m   i n   a r r K e y s  
                         I f   L e n ( i t e m )   >   3 7   T h e n  
                                 s G u i d   =   U C a s e ( L e f t ( i t e m ,   3 8 ) )  
                                 I f   C h e c k D e l e t e ( s G u i d )   T h e n   R e g D e l e t e K e y   H K L M ,   R E G _ A R P   &   i t e m   &   " \ "  
                         E n d   I f   ' L e n ( I t e m ) > 3 7  
                 N e x t   ' I t e m  
         E n d   I f  
  
         '   U p g r a d e C o d e s ,   W I   c o n f i g ,   W I   g l o b a l   c o n f i g  
         L o g H 2   " S c a n n i n g   W i n d o w s   I n s t a l l e r   m e t a d a t a   f o r   r e m o v e a b l e   U p g r a d e C o d e s "  
         F o r   i L o o p C n t   =   1   t o   5  
                 S e l e c t   C a s e   i L o o p C n t  
                 C a s e   1  
                         s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ I n s t a l l e r \ U p g r a d e C o d e s \ "  
                         h D e f K e y   =   H K L M  
                 C a s e   2    
                         s S u b K e y N a m e   =   " I n s t a l l e r \ U p g r a d e C o d e s \ "  
                         h D e f K e y   =   H K C R  
                 C a s e   3  
                         s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ I n s t a l l e r \ U s e r D a t a \ S - 1 - 5 - 1 8 \ P r o d u c t s \ "  
                         h D e f K e y   =   H K L M  
                 C a s e   4    
                         s S u b K e y N a m e   =   " I n s t a l l e r \ F e a t u r e s \ "  
                         h D e f K e y   =   H K C R  
                 C a s e   5    
                         s S u b K e y N a m e   =   " I n s t a l l e r \ P r o d u c t s \ "  
                         h D e f K e y   =   H K C R  
                 E n d   S e l e c t  
                 I f   R e g E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )   T h e n  
                         F o r   E a c h   i t e m   i n   a r r K e y s  
                                 '   e n s u r e   t h e   e x p e c t e d   l e n g t h   f o r   a   c o m p r e s s e d   G U I D  
                                 I f   L e n ( i t e m )   =   3 2   T h e n  
                                         '   e x p a n d   t h e   G U I D  
                                         s G u i d   =   G e t E x p a n d e d G u i d ( i t e m )    
                                         '   c h e c k   i f   i t ' s   a n   O f f i c e   k e y  
                                         I f   C h e c k D e l e t e ( s G u i d )   T h e n  
                                                 I f   i L o o p C n t   <   3   T h e n  
                                                         '   e n u m   a l l   e n t r i e s  
                                                         R e g E n u m V a l u e s   h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r N a m e s ,   a r r T y p e s  
                                                         I f   I s A r r a y ( a r r N a m e s )   T h e n  
                                                                 '   d e l e t e   e n t r i e s   w i t h i n   r e m o v a l   s c o p e  
                                                                 F o r   E a c h   n a m e   i n   a r r N a m e s  
                                                                         I f   L e n ( n a m e )   =   3 2   T h e n  
                                                                                 s G u i d   =   G e t E x p a n d e d G u i d ( n a m e )  
                                                                                 I f   C h e c k D e l e t e ( s G u i d )   T h e n   R e g D e l e t e V a l u e   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ " ,   n a m e ,   T r u e  
                                                                         E l s e  
                                                                                 '   i n v a l i d   d a t a   - >   d e l e t e   t h e   v a l u e  
                                                                                 R e g D e l e t e V a l u e   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ " ,   n a m e ,   T r u e  
                                                                         E n d   I f  
                                                                 N e x t   ' N a m e  
                                                         E n d   I f   ' I s A r r a y ( a r r N a m e s )  
                                                         '   i f   a l l   e n t r i e s   w e r e   r e m o v e d   -   d e l e t e   t h e   k e y  
                                                         I f   N O T   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r N a m e s ,   a r r T y p e s )   T h e n   R e g D e l e t e K e y   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ "  
                                                 E l s e   ' i L o o p C n t   > =   3  
                                                         R e g D e l e t e K e y   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ "  
                                                 E n d   I f   ' i L o o p C n t   <   3  
                                         E n d   I f   ' I n S c o p e  
                                 E n d   I f   ' L e n ( I t e m ) = 3 2  
                         N e x t   ' I t e m  
                 E n d   I f   ' R e g E n u m K e y  
         N e x t   ' i L o o p C n t  
  
         '   C o m p o n e n t s   i n   G l o b a l  
         L o g H 2   " S c a n n i n g   W i n d o w s   I n s t a l l e r   G l o b a l   C o m p o n e n t s   m e t a d a t a "  
         s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ I n s t a l l e r \ U s e r D a t a \ S - 1 - 5 - 1 8 \ C o m p o n e n t s \ "  
         h D e f K e y   =   H K L M  
         I f   R e g E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )   T h e n  
                 F o r   E a c h   i t e m   i n   a r r K e y s  
                         '   e n s u r e   t h e   e x p e c t e d   l e n g t h   f o r   a   c o m p r e s s e d   G U I D  
                         I f   L e n ( I t e m )   =   3 2   T h e n  
                                 I f   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r N a m e s ,   a r r T y p e s )   T h e n  
                                         F o r   E a c h   n a m e   i n   a r r N a m e s  
                                                 I f   L e n ( N a m e )   =   3 2   T h e n  
                                                         s G u i d   =   G e t E x p a n d e d G u i d ( N a m e )  
                                                         I f   C h e c k D e l e t e ( s G u i d )   T h e n  
                                                                 R e g D e l e t e V a l u e   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ " ,   n a m e ,   F a l s e  
                                                                 '   i f   a l l   e n t r i e s   w e r e   r e m o v e d   -   d e l e t e   t h e   k e y  
                                                                 I f   N O T   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r T e s t N a m e s ,   a r r T e s t T y p e s )   T h e n   R e g D e l e t e K e y   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ "  
                                                         E n d   I f  
                                                 E n d   I f   ' 3 2  
                                         N e x t   ' N a m e  
                                 E n d   I f   ' R e g E n u m V a l u e s  
                         E n d   I f   ' 3 2  
                 N e x t   ' I t e m  
         E n d   I f   ' R e g E n u m K e y  
  
         '   P u b l i s h e d   C o m p o n e n t s  
         L o g H 2   " S c a n n i n g   W i n d o w s   I n s t a l l e r   P u b l i s h e d   C o m p o n e n t s   m e t a d a t a "  
         s S u b K e y N a m e   =   " I n s t a l l e r \ C o m p o n e n t s \ "  
         h D e f K e y   =   H K C R  
         I f   R e g E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )   T h e n  
                 F o r   E a c h   i t e m   i n   a r r K e y s  
                         '   e n s u r e   t h e   e x p e c t e d   l e n g t h   f o r   a   c o m p r e s s e d   G U I D  
                         I f   L e n ( I t e m )   =   3 2   T h e n  
                                 I f   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r N a m e s ,   a r r T y p e s )   T h e n  
                                         F o r   E a c h   n a m e   i n   a r r N a m e s  
                                                 I f   R e g R e a d V a l u e   ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   n a m e ,   s V a l u e ,   " R E G _ M U L T I _ S Z " )   T h e n  
                                                         a r r M u l t i S z V a l u e s   =   S p l i t ( s V a l u e ,   c h r ( 1 3 ) )  
                                                         I f   I s A r r a y ( a r r M u l t i S z V a l u e s )   T h e n  
                                                                 i   =   - 1  
                                                                 R e D i m   a r r M u l t i S z N e w V a l u e s ( - 1 )  
                                                                 f D e l R e g   =   F a l s e  
                                                                 F o r   E a c h   v a l u e   i n   a r r M u l t i S z V a l u e s  
                                                                         I f   L e n ( v a l u e )   >   1 9   T h e n  
                                                                                 s G u i d   =   " "  
                                                                                 I f   G e t D e c o d e d G u i d ( L e f t ( v a l u e ,   S Q U I S H E D ) ,   s G u i d )   T h e n  
                                                                                         I f   C h e c k D e l e t e ( s G u i d )   T h e n  
                                                                                                 f D e l R e g   =   T r u e  
                                                                                         E l s e  
                                                                                                 i   =   i   +   1    
                                                                                                 R e D i m   P r e s e r v e   a r r M u l t i S z N e w V a l u e s ( i )  
                                                                                                 a r r M u l t i S z N e w V a l u e s ( i )   =   v a l u e  
                                                                                         E n d   I f   ' C h e c k D e l e t e  
                                                                                 E n d   I f   ' d e c o d e  
                                                                         E n d   I f   ' 1 9  
                                                                 N e x t   ' V a l u e  
                                                                 I f   N O T   ( i   =   - 1 )   T h e n  
                                                                         I f   N O T   U B o u n d ( a r r M u l t i S z V a l u e s )   =   i   T h e n   o R e g . S e t M u l t i S t r i n g V a l u e   h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   n a m e , a r r M u l t i S z N e w V a l u e s  
                                                                 E l s e  
                                                                         I f   f D e l R e g   T h e n  
                                                                                 R e g D e l e t e V a l u e   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ " ,   n a m e ,   T r u e  
                                                                                 '   i f   a l l   e n t r i e s   w e r e   r e m o v e d   -   d e l e t e   t h e   k e y  
                                                                                 I f   N O T   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e   &   i t e m ,   a r r T e s t N a m e s ,   a r r T e s t T y p e s )   T h e n   R e g D e l e t e K e y   h D e f K e y ,   s S u b K e y N a m e   &   i t e m   &   " \ "  
                                                                         E n d   I f   ' D e l R e g  
                                                                 E n d   I f  
                                                         E n d   I f   ' I s A r r a y  
                                                 E n d   I f  
                                         N e x t   ' N a m e  
                                 E n d   I f   ' R e g E n u m V a l u e s  
                         E n d   I f   ' 3 2  
                 N e x t   ' I t e m  
         E n d   I f   ' R e g E n u m K e y  
  
 E n d   S u b   ' R e g w i p e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       F i l e W i p e  
 '  
 '       R e m o v a l   o f   l e f t   b e h i n d   s e r v i c e s ,   f i l e s   a n d   s h o r t c u t s    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   F i l e W i p e  
         D i m   s c R o o t  
         D i m   f D e l F o l d e r s  
          
         I f   C B o o l ( i E r r o r   A N D   E R R O R _ U S E R C A N C E L )   T h e n   E x i t   S u b  
  
         L o g H 1   " F i l e   C l e a n u p "    
  
         f D e l F o l d e r s   =   F a l s e  
         C l o s e O f f i c e A p p s  
         D e l S c h t a s k s  
  
         '   r e m o v e   t h e   O f f i c e S v c   s e r v i c e  
         L o g H 2   " D e l e t i n g   O f f i c e S v c   s e r v i c e "  
         D e l e t e S e r v i c e   " O f f i c e S v c "  
  
         '   S P 1   a d d i t i o n   /   c h a n g e  
         '   r e m o v e   t h e   C l i c k T o R u n S v c   s e r v i c e  
         L o g H 2   " D e l e t i n g   C l i c k T o R u n S v c   s e r v i c e "    
         D e l e t e S e r v i c e   " C l i c k T o R u n S v c "  
  
         '   a d d i n g   a d d i t i o n a l   p r o c e s s e s   f o r   t e r m i n a t i o n  
         d i c A p p s . A d d   " e x p l o r e r . e x e " ,   " e x p l o r e r . e x e "  
         d i c A p p s . A d d   " m s i e x e c . e x e " ,   " m s i e x e c . e x e "  
         d i c A p p s . A d d   " o s e . e x e " ,   " o s e . e x e "  
          
         I f   f C 2 R   T h e n  
 	         '   d e l e t e   C 2 R   p a c k a g e   f i l e s  
                 L o g H 2   " D e l e t i n g   C 2 R   p a c k a g e   f i l e s "    
                 I f   o F s o . F o l d e r E x i s t s ( s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e   1 5 " )   _  
                 O r   o F s o . F o l d e r E x i s t s ( s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e   1 6 " )   _  
                 O r   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s % " )   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s " )   _  
                 O r   o F s o . F o l d e r E x i s t s ( o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % p r o g r a m f i l e s ( x 8 6 ) % " )   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s " )   T h e n  
                         f D e l F o l d e r s   =   T r u e  
                         L o g   "       A t t e n t i o n :   N o w   c l o s i n g   E x p l o r e r . e x e   f o r   f i l e   d e l e t e   o p e r a t i o n s "  
                         L o g   "       E x p l o r e r   w i l l   a u t o m a t i c a l l y   r e s t a r t . "  
                         w s c r i p t . s l e e p   2 0 0 0  
                         C l o s e O f f i c e A p p s  
                 E n d   I f  
                 '   d e l e t e   O f f i c e   f o l d e r s  
                 L o g H 2   " D e l e t i n g   O f f i c e   f o l d e r s "  
                 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e   1 5 "  
                 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e   1 6 "  
                 I f   f 6 4   T h e n    
                 	 D e l e t e F o l d e r   s C o m m o n P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e   1 5 "  
                 	 D e l e t e F o l d e r   s C o m m o n P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e   1 6 "  
                 E n d   I f  
                 I f   f D e l F o l d e r s   T h e n  
                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s "  
                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e S u n r i s e P o l i c i e s "  
                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ r o o t "  
                 	 D e l e t e F i l e   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ A p p X M a n i f e s t . x m l "  
                   	 D e l e t e F i l e   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ F i l e S y s t e m M e t a d a t a . x m l "  
                 	 I f   N o t   d i c K e e p S k u . C o u n t   >   0   T h e n    
                 	 	 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 6 "  
                 	 	 D e l e t e F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 5 "  
                 	 E n d   I f  
                 	 I f   f 6 4   T h e n  
 	                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s "  
 	                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ P a c k a g e S u n r i s e P o l i c i e s "  
 	                 	 D e l e t e F o l d e r   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ r o o t "  
 	                 	 D e l e t e F i l e   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ A p p X M a n i f e s t . x m l "  
 	                   	 D e l e t e F i l e   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ F i l e S y s t e m M e t a d a t a . x m l "  
 	                 	 I f   N o t   d i c K e e p S k u . C o u n t   >   0   T h e n    
 	                 	 	 D e l e t e F o l d e r   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 6 "  
 	                 	 	 D e l e t e F o l d e r   s P r o g r a m F i l e s X 8 6   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 5 "  
 	                 	 E n d   I f  
               	 	 E n d   I f  
 	 	 E n d   I f  
                  
                 D e l e t e F o l d e r   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ C l i c k T o R u n "  
                 D e l e t e F o l d e r   s C o m m o n P r o g r a m F i l e s   &   " \ m i c r o s o f t   s h a r e d \ C l i c k T o R u n "  
                 D e l e t e F o l d e r   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ F F P a c k a g e L o c k e r "  
                 D e l e t e F o l d e r   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ C l i c k T o R u n P a c k a g e L o c k e r "  
                 I f   o F s o . F i l e E x i s t s ( s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ F F P a c k a g e L o c k e r " )   T h e n   D e l e t e F i l e   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ F F P a c k a g e L o c k e r "  
                 I f   o F s o . F i l e E x i s t s ( s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ F F S t a t e P B L o c k e r " )   T h e n   D e l e t e F i l e   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ F F S t a t e P B L o c k e r "  
                 I f   N O T   d i c K e e p S k u . C o u n t   >   0   T h e n   D e l e t e F o l d e r   s P r o g r a m D a t a   &   " \ M i c r o s o f t \ o f f i c e \ H e a r t b e a t "  
                 D e l e t e F o l d e r   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % u s e r p r o f i l e % " )   &   " \ M i c r o s o f t   O f f i c e "  
                 D e l e t e F o l d e r   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % u s e r p r o f i l e % " )   &   " \ M i c r o s o f t   O f f i c e   1 5 "  
                 D e l e t e F o l d e r   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % u s e r p r o f i l e % " )   &   " \ M i c r o s o f t   O f f i c e   1 6 "  
         E n d   I f  
  
         '   r e s t o r e   e x p l o r e r . e x e   i f   n e e d e d  
         R e s t o r e E x p l o r e r  
  
         '   d e l e t e   s h o r t c u t s  
         L o g H 2   " S e a r c h   a n d   d e l e t e   s h o r t c u t s "  
         C l e a n S h o r t c u t s   s A l l U s e r s P r o f i l e ,   T r u e ,   F a l s e  
         C l e a n S h o r t c u t s   s P r o f i l e s D i r e c t o r y ,   T r u e ,   F a l s e  
  
         '   d e l e t e   e m p t y   f o l d e r   s t r u c t u r e s  
         I f   d i c D e l F o l d e r . C o u n t   >   0   T h e n  
                 L o g H 2   " R e m o v i n g   e m p t y   f o l d e r s "  
                 D e l e t e E m p t y F o l d e r s  
         E n d   I f  
  
         '   a d d   t h e   c o l l e c t e d   f i l e s   i n   u s e   f o r   d e l e t e   o n   r e b o o t  
         I f   d i c D e l I n U s e . C o u n t   >   0   T h e n   S c h e d u l e D e l e t e E x  
  
         L o g H 2   " F i l e   C l e a n u p   c o m p l e t e "  
 E n d   S u b   '   F i l e W i p e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C l e a n S h o r t c u t s  
 '  
 '       R e c u r s i v e l y   s e a r c h   a l l   p r o f i l e   f o l d e r s   f o r   O f f i c e   s h o r t c u t s   i n   s c o p e    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C l e a n S h o r t c u t s   ( s F o l d e r ,   f D e l e t e ,   f U n P i n )  
         D i m   o F o l d e r ,   f l d ,   f i l e ,   s c ,   i t e m  
         D i m   f D e l e t e S C  
  
 	 S e t   o F o l d e r   =   o F s o . G e t F o l d e r ( s F o l d e r )  
 	 '   e x c l u d e   s y s t e m   p r o t e c t e d   l i n k   f o l d e r s  
         I f   C B o o l ( o F o l d e r . A t t r i b u t e s   A N D   1 0 2 4 )   T h e n   E x i t   S u b  
  
         O n   E r r o r   R e s u m e   N e x t  
         F o r   E a c h   f l d   I n   o F o l d e r . S u b F o l d e r s  
                 I f   E r r   < >   0   T h e n  
 	 	         C h e c k E r r o r   " C l e a n S h o r t c u t s :   "   &   v b T a b   &   s F o l d e r  
                 E l s e  
                         C l e a n S h o r t c u t s   f l d . P a t h ,   f D e l e t e ,   f U n P i n  
                 E n d   I f  
 	 N e x t  
         F o r   E a c h   f i l e   I n   o F o l d e r . F i l e s  
 	 	 I f   L C a s e ( R i g h t ( f i l e . P a t h ,   4 ) )   =   " . l n k "   T h e n  
                         f D e l e t e S C   =   F a l s e  
                         L o g O n l y   "   c h e c k   f i l e :   "   &   f i l e . P a t h  
                         s e t   s c   =   o W S h e l l . C r e a t e S h o r t c u t ( f i l e . P a t h )  
                         I f   E r r   < >   0   T h e n  
 	 	                 C h e c k E r r o r   " C l e a n S h o r t c u t s S C :   "   &   v b T a b   &   s F o l d e r  
                         E l s e  
                                 ' C o m p a r e   i f   t h e   s h o r t c u t   t a r g e t   i s   i n   t h e   l i s t   o f   e x e c u t a b l e s   t h a t   w i l l   b e   r e m o v e d  
                                 ' L o g O n l y   "     -   S C . T a r g e t P a t h :   "   &   s c . T a r g e t P a t h  
                                 I f   L e n ( s c . T a r g e t P a t h )   >   0   T h e n  
                                         I f   I n S t r ( s c . T a r g e t P a t h , " { " )   >   0   T h e n  
                                                 ' H a n d l e   W i n d o w s   I n s t a l l e r   s h o r t c u t s  
                                                 I f   L e n ( s c . T a r g e t P a t h )   > =   I n S t r ( s c . T a r g e t P a t h , " { " )   +   3 7   T h e n  
                                                         I f   C h e c k D e l e t e ( M i d ( s c . T a r g e t P a t h ,   I n S t r ( s c . T a r g e t P a t h , " { " ) ,   3 8 ) )   T h e n   f D e l e t e S C   =   T r u e  
                                                 E n d   I f  
                                         E l s e  
                                                 ' H a n d l e   r e g u l a r   s h o r t c u t s  
                                                 I f   I s C 2 R ( s c . T a r g e t P a t h )   T h e n   f D e l e t e S C   =   T r u e  
                                                 I f   N O T   o F s o . F i l e E x i s t s ( s c . T a r g e t P a t h )   T h e n  
                                                         '   S h o r t c u t   t a r g e t   d o e s   n o t   e x i s t  
                                                         I f   I s C 2 R ( s c . T a r g e t P a t h )   T h e n  
                                                                 L o g O n l y   " r e m o v i n g   O f f i c e   s h o r t c u t   w i t h   n o n - e x i s t e n t   t a r g e t :   "   &   f i l e . P a t h   &   "   -   "   &   s c . T a r g e t P a t h  
                                                                 f D e l e t e S C   =   T r u e  
                                                         E l s e  
                                                                 ' L o g O n l y   "     -   k e e p   o r p h a n e d   S C   a s   t a r g e t   i s   n o t   i n   s c o p e :   "   &   s c . T a r g e t P a t h  
                                                         E n d   I f  
                                                 E l s e  
                                                         ' L o g O n l y   "     -   k e e p   S C   a s   s h o r t c u t   t a r g e t   d o e s   s t i l l   e x i s t :   "   &   s c . T a r g e t P a t h  
                                                 E n d   I f  
                                         E n d   I f  
                                 E n d   I f  
                         E n d   I f  
                         I f   f D e l e t e S C   T h e n    
                                 I f   N O T   d i c D e l F o l d e r . E x i s t s ( s F o l d e r )   T h e n   d i c D e l F o l d e r . A d d   s F o l d e r ,   s F o l d e r  
                                 I f   f U n P i n   T h e n   U n P i n   f i l e  
                                 I f   f D e l e t e   T h e n  
                                         U n P i n   f i l e  
                                         D e l e t e F i l e   f i l e . P a t h  
                                 E n d   I f  
                                 f D e l e t e S C   =   F a l s e  
                         E n d   I f   ' f D e l e t e S C  
                 E n d   I f  
 	 N e x t  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' C l e a n S h o r t c u t s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       U n P i n  
 '  
 '       U n p i n s   a   s h o r t c u t   f r o m   t h e   t a s k b a r   o r   s t a r t   m e n u    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   U n P i n ( f i l e )  
         D i m   f l d I t e m ,   v e r b  
  
         O n   E r r o r   R e s u m e   N e x t  
         S e t   f l d I t e m   =   o S h e l l A p p . N a m e S p a c e ( f i l e . P a r e n t F o l d e r . P a t h ) . P a r s e N a m e ( f i l e . N a m e )  
         F o r   E a c h   v e r b   i n   f l d I t e m . V e r b s  
                 S e l e c t   C a s e   R e p l a c e ( v e r b ,   " & " ,   " " )  
                 C a s e   " U n p i n   f r o m   T a s k b a r " ,   " V o n   T a s k l e i s t e   l ö s e n " ,   " D é t a c h e r   d u   b a r r e   d e s   t â c h e s " ,   " D é t a c h e r   d e   l a   b a r r e   d e s   t â c h e s " ,   " D e s a n c l a r   d e   l a   b a r r a   d e   t a r e a s " ,   " T a   b o r t   f r å n   A k t i v i t e t s f ä l t e t " ,   " ¿0¹0¯0  Ð0ü0k0hˆ:yW0j0D0( K ) " ,   " ‘ÇÅÅ  \ÔÜÂÉÐÅÁ  Èp¬( K ) " ,   " B:@5?8BL  >B  ?0=5;8  7040G"  
                         v e r b . D o I t  
                 C a s e   " U n p i n   f r o m   S t a r t   M e n u " ,   " V o m   S t a r t m e n ü   l ö s e n " ,   " D é t a c h e r   d u   m e n u   D é m a r r e r " ,   " D é t a c h e r   d e   l a   m e n u   D é m a r r e r "  
                         I f   i V e r s i o n N T   >   6 0 0   T h e n   v e r b . D o I t  
                 E n d   S e l e c t  
         N e x t  
         O n   E r r o r   G o t o   0  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C l e a r O f f i c e H K L M  
 '  
 '       R e c u r s i v e l y   s e a r c h   a n d   c l e a r   t h e   H K L M   O f f i c e   k e y   f r o m   r e f e r e n c e s   i n   s c o p e    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C l e a r O f f i c e H K L M   ( s S u b K e y N a m e )  
         D i m   k e y ,   n a m e  
         D i m   s V a l u e  
         D i m   a r r K e y s ,   a r r N a m e s ,   a r r T y p e s  
         D i m   a r r T e s t N a m e s ,   a r r T e s t T y p e s ,   a r r T e s t K e y s  
  
         '   r e c u r s i o n  
         I f   R e g E n u m K e y ( H K L M ,   s S u b K e y N a m e ,   a r r K e y s )   T h e n  
                 F o r   E a c h   k e y   i n   a r r K e y s  
                         C l e a r O f f i c e H K L M   s S u b K e y N a m e   &   " \ "   &   k e y  
                 N e x t   ' k e y  
         E n d   I f  
          
         '   i d e n t i f y   &   c l e a r   r e m o v a b l e   e n t r i e s  
         I f   R e g E n u m V a l u e s ( H K L M ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s )   T h e n  
                 F o r   E a c h   n a m e   i n   a r r N a m e s  
                         I f   R e g R e a d V a l u e ( H K L M ,   s S u b K e y N a m e ,   n a m e ,   s V a l u e ,   " R E G _ S Z " )   T h e n  
                                 I f   I s C 2 R ( s V a l u e )   T h e n   R e g D e l e t e V a l u e   H K L M ,   s S u b K e y N a m e ,   n a m e ,   F a l s e  
                         E n d   I f  
                 N e x t   ' i t e m  
         E n d   I f  
          
         '   c l e a r   o u t   e m p t y   k e y s  
         I f   ( N O T   R e g E n u m V a l u e s ( H K L M ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s ) )   A N D   _  
               ( N O T   R e g E n u m K e y ( H K L M ,   s S u b K e y N a m e ,   a r r K e y s ) )   A N D   _  
               ( N O T   d i c K e e p S k u . C o u n t   >   0 )   T h e n   _  
                 R e g D e l e t e K e y   H K L M ,   s S u b K e y N a m e  
 E n d   S u b  
  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '  
 '                                                                                 H e l p e r   F u n c t i o n s  
 '  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       I s C 2 R  
 '  
 '       C h e c k   i f   t h e   p a s s e d   i n   s t r i n g   i s   r e l a t e d   t o   C 2 R  
 '       R e t u r n s   T R U E   i f   i n   C 2 R   s c o p e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   I s C 2 R   ( s V a l u e )  
  
 	 C o n s t   O R E F                         =   " \ R O O T \ O F F I C E 1 "  
 	 C o n s t   O R E F R O O T                 =   " M i c r o s o f t   O f f i c e \ R o o t \ "  
 	 C o n s t   O R E G R E F C 2 R 1 5         =   " M i c r o s o f t   O f f i c e   1 5 "  
 	 C o n s t   O R E G R E F C 2 R 1 6         =   " M i c r o s o f t   O f f i c e   1 6 "  
 	 C o n s t   O C O M M O N 	 	     =   " \ m i c r o s o f t   s h a r e d \ C l i c k T o R u n "  
 	 C o n s t   O M A N I F E S T 	 	     =   " \ M i c r o s o f t   O f f i c e \ P a c k a g e M a n i f e s t s "  
 	 C o n s t   O S U N R I S E 	 	     =   " \ M i c r o s o f t   O f f i c e \ P a c k a g e S u n r i s e P o l i c i e s "  
 	  
 	 D i m   f R e t u r n  
 	  
 	 f R e t u r n   =   F a l s e  
 	  
         I f   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O R E F ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O R E F R O O T ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O C O M M O N ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O M A N I F E S T ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O S U N R I S E ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O R E G R E F C 2 R 1 5 ) )   >   0   _  
         O r   I n S t r ( L C a s e ( s V a l u e ) ,   L C a s e ( O R E G R E F C 2 R 1 6 ) )   >   0   T h e n   f R e t u r n   =   T r u e  
          
 	 I s C 2 R   =   f R e t u r n  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C h e c k R e g P e r m i s s i o n s  
 '  
 '       T e s t   t h e   p e r m i s s i o n s   o n   s o m e   k e y   r e g i s t r y   l o c a t i o n s   t o   d e t e r m i n e   i f    
 '       s u f f i c i e n t   p e r m i s s i o n s   a r e   g i v e n .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   C h e c k R e g P e r m i s s i o n s  
         C o n s t   K E Y _ Q U E R Y _ V A L U E               =   & H 0 0 0 1  
         C o n s t   K E Y _ S E T _ V A L U E                   =   & H 0 0 0 2  
         C o n s t   K E Y _ C R E A T E _ S U B _ K E Y         =   & H 0 0 0 4  
         C o n s t   D E L E T E                                 =   & H 0 0 0 1 0 0 0 0  
  
         D i m   s S u b K e y N a m e  
         D i m   f R e t u r n  
  
         C h e c k R e g P e r m i s s i o n s   =   T r u e  
         s S u b K e y N a m e   =   " S o f t w a r e \ M i c r o s o f t \ W i n d o w s \ "  
         o R e g . C h e c k A c c e s s   H K L M ,   s S u b K e y N a m e ,   K E Y _ Q U E R Y _ V A L U E ,   f R e t u r n  
         I f   N o t   f R e t u r n   T h e n   C h e c k R e g P e r m i s s i o n s   =   F a l s e  
         o R e g . C h e c k A c c e s s   H K L M ,   s S u b K e y N a m e ,   K E Y _ S E T _ V A L U E ,   f R e t u r n  
         I f   N o t   f R e t u r n   T h e n   C h e c k R e g P e r m i s s i o n s   =   F a l s e  
         o R e g . C h e c k A c c e s s   H K L M ,   s S u b K e y N a m e ,   K E Y _ C R E A T E _ S U B _ K E Y ,   f R e t u r n  
         I f   N o t   f R e t u r n   T h e n   C h e c k R e g P e r m i s s i o n s   =   F a l s e  
         o R e g . C h e c k A c c e s s   H K L M ,   s S u b K e y N a m e ,   D E L E T E ,   f R e t u r n  
         I f   N o t   f R e t u r n   T h e n   C h e c k R e g P e r m i s s i o n s   =   F a l s e  
  
 E n d   F u n c t i o n   ' C h e c k R e g P e r m i s s i o n s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       G e t M y P r o c e s s I d  
 '  
 '       R e t u r n s   t h e   p r o c e s s   i d   o f   t h e   o w n   p r o c e s s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   G e t M y P r o c e s s I d ( )  
         D i m   i P a r e n t P r o c e s s I d  
  
         i P a r e n t P r o c e s s I d   =   0  
         '   t r y   t o   o b t a i n   f r o m   c r e a t i n g   a   n e w   c s c r i p t   i n s t a n c e  
         O n   E r r o r   R e s u m e   N e x t  
         i P a r e n t P r o c e s s I d   =   G e t O b j e c t ( " w i n m g m t s : r o o t \ c i m v 2 " ) . G e t ( " W i n 3 2 _ P r o c e s s . H a n d l e = ' "   &   o W S h e l l . E x e c ( " c s c r i p t . e x e " ) . P r o c e s s I d   &   " ' " ) . P a r e n t P r o c e s s I d  
         O n   E r r o r   G o t o   0  
         I f   i P a r e n t P r o c e s s I d   >   0   T h e n  
                 '   s u c c e e d e d   t o   o b t a i n   t h e   p r o c e s s   i d  
                 G e t M y P r o c e s s I d   =   i P a r e n t P r o c e s s I d  
                 E x i t   F u n c t i o n  
         E n d   I f  
  
         '   f a i l e d   t o   o b t a i n   t h e   i d   f r o m   t h e   c r e a t i o n   o f   a   n e w   i n s t a n c e  
         '   g e t   i t   f r o m   e n u m   o f   W i n 3 2 _ P r o c e s s  
         D i m   P r o c e s s ,   P r o c e s s e s  
         E r r . C l e a r  
         S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W H E R E   N a m e = ' c s c r i p t . e x e '   A N D   C o m m a n d L i n e   l i k e   ' % "   &   S C R I P T N A M E   &   " % ' " )  
         F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
                 i P a r e n t P r o c e s s I d   =   P r o c e s s . P r o c e s s I d  
                 E x i t   F o r  
         N e x t  
         G e t M y P r o c e s s I d   =   i P a r e n t P r o c e s s I d  
 E n d   F u n c t i o n   ' G e t M y P r o c e s s I d  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l i m i t e r  
 '  
 '       R e t u r n s   t h e   d e l i m i t e r   f o r   a   p a s s e d   i n   s t r i n g  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   D e l i m i t e r   ( s V e r s i o n )  
         D i m   i C n t ,   i A s c  
  
         D e l i m i t e r   =   "   "  
         F o r   i C n t   =   1   T o   L e n ( s V e r s i o n )  
                 i A s c   =   A s c ( M i d ( s V e r s i o n ,   i C n t ,   1 ) )  
                 I f   N o t   ( i A S C   > =   4 8   A n d   i A S C   < =   5 7 )   T h e n    
                         D e l i m i t e r   =   M i d ( s V e r s i o n ,   i C n t ,   1 )  
                         E x i t   F u n c t i o n  
                 E n d   I f  
         N e x t   ' i C n t  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       G e t E x p a n d e d G u i d  
 '  
 '       R e t u r n s   t h e   e x p a n d e d   s t r i n g   f r o m   a   c o m p r e s s e d   G U I D  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   G e t E x p a n d e d G u i d   ( s G u i d )  
         D i m   i  
  
         ' E n s u r e   v a l i d   l e n g t h  
         I f   N O T   L e n ( s G u i d )   =   3 2   T h e n   E x i t   F u n c t i o n  
  
         G e t E x p a n d e d G u i d   =   " { "   &   S t r R e v e r s e ( M i d ( s G u i d , 1 , 8 ) )   &   " - "   &   _  
                                               S t r R e v e r s e ( M i d ( s G u i d , 9 , 4 ) )   &   " - "   &   _  
                                               S t r R e v e r s e ( M i d ( s G u i d , 1 3 , 4 ) ) &   " - "  
         F o r   i   =   1 7   T o   2 0  
 	         I f   i   M o d   2   T h e n  
 	 	         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   m i d ( s G u i d , ( i   +   1 ) , 1 )  
 	         E l s e  
 	 	         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   m i d ( s G u i d , ( i   -   1 ) , 1 )  
 	         E n d   I f  
         N e x t  
         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   " - "  
         F o r   i   =   2 1   T o   3 2  
 	         I f   i   M o d   2   T h e n  
 	 	         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   m i d ( s G u i d , ( i   +   1 ) , 1 )  
 	         E l s e  
 	 	         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   m i d ( s G u i d , ( i   -   1 ) , 1 )  
 	         E n d   I f  
         N e x t  
         G e t E x p a n d e d G u i d   =   G e t E x p a n d e d G u i d   &   " } "  
 E n d   F u n c t i o n   ' G e t E x p a n d e d G u i d  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       G e t C o m p r e s s e d G u i d  
 '  
 '       R e t u r n s   t h e   c o m p r e s s e d   s t r i n g   f o r   a   G U I D  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   G e t C o m p r e s s e d G u i d   ( s G u i d )  
         D i m   s C o m p G U I D  
         D i m   i  
          
         ' E n s u r e   V a l i d   L e n g t h  
         I f   N O T   L e n ( s G u i d )   =   3 8   T h e n   E x i t   F u n c t i o n  
  
         s C o m p G U I D   =   S t r R e v e r s e ( M i d ( s G u i d , 2 , 8 ) )     &   _  
                                 S t r R e v e r s e ( M i d ( s G u i d , 1 1 , 4 ) )   &   _  
                                 S t r R e v e r s e ( M i d ( s G u i d , 1 6 , 4 ) )    
         F o r   i   =   2 1   T o   2 4  
 	         I f   i   M o d   2   T h e n  
 	 	         s C o m p G U I D   =   s C o m p G U I D   &   M i d ( s G u i d ,   ( i   +   1 ) ,   1 )  
 	         E l s e  
 	 	         s C o m p G U I D   =   s C o m p G U I D   &   M i d ( s G u i d ,   ( i   -   1 ) ,   1 )  
 	         E n d   I f  
         N e x t  
         F o r   i   =   2 6   T o   3 7  
 	         I f   i   M o d   2   T h e n  
 	 	         s C o m p G U I D   =   s C o m p G U I D   &   M i d ( s G u i d ,   ( i   -   1 ) ,   1 )  
 	         E l s e  
 	 	         s C o m p G U I D   =   s C o m p G U I D   &   M i d ( s G u i d ,   ( i   +   1 ) ,   1 )  
 	         E n d   I f  
         N e x t  
         G e t C o m p r e s s e d G u i d   =   s C o m p G U I D  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       G e t D e c o d e d G u i d  
 '  
 '       R e t u r n s   t h e   G U I D   f r o m   a   s q u i s h e d   f o r m a t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   G e t D e c o d e d G u i d ( s E n c G u i d ,   s G u i d )  
  
 D i m   s D e c o d e ,   s T a b l e ,   s H e x ,   i C h r  
 D i m   a r r T a b l e  
 D i m   i ,   i A s c ,   p o w 8 5 ,   d e c C h a r  
 D i m   l T o t a l  
 D i m   f F a i l e d  
  
         f F a i l e d   =   F a l s e  
  
         s T a b l e   =         " 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , "   &   _  
                                 " 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , 0 x f f , "   &   _  
                                 " 0 x f f , 0 x 0 0 , 0 x f f , 0 x f f , 0 x 0 1 , 0 x 0 2 , 0 x 0 3 , 0 x 0 4 , 0 x 0 5 , 0 x 0 6 , 0 x 0 7 , 0 x 0 8 , 0 x 0 9 , 0 x 0 a , 0 x 0 b , 0 x f f , "   &   _  
                                 " 0 x 0 c , 0 x 0 d , 0 x 0 e , 0 x 0 f , 0 x 1 0 , 0 x 1 1 , 0 x 1 2 , 0 x 1 3 , 0 x 1 4 , 0 x 1 5 , 0 x f f , 0 x f f , 0 x f f , 0 x 1 6 , 0 x f f , 0 x 1 7 , "   &   _  
                                 " 0 x 1 8 , 0 x 1 9 , 0 x 1 a , 0 x 1 b , 0 x 1 c , 0 x 1 d , 0 x 1 e , 0 x 1 f , 0 x 2 0 , 0 x 2 1 , 0 x 2 2 , 0 x 2 3 , 0 x 2 4 , 0 x 2 5 , 0 x 2 6 , 0 x 2 7 , "   &   _  
                                 " 0 x 2 8 , 0 x 2 9 , 0 x 2 a , 0 x 2 b , 0 x 2 c , 0 x 2 d , 0 x 2 e , 0 x 2 f , 0 x 3 0 , 0 x 3 1 , 0 x 3 2 , 0 x 3 3 , 0 x f f , 0 x 3 4 , 0 x 3 5 , 0 x 3 6 , "   &   _  
                                 " 0 x 3 7 , 0 x 3 8 , 0 x 3 9 , 0 x 3 a , 0 x 3 b , 0 x 3 c , 0 x 3 d , 0 x 3 e , 0 x 3 f , 0 x 4 0 , 0 x 4 1 , 0 x 4 2 , 0 x 4 3 , 0 x 4 4 , 0 x 4 5 , 0 x 4 6 , "   &   _  
                                 " 0 x 4 7 , 0 x 4 8 , 0 x 4 9 , 0 x 4 a , 0 x 4 b , 0 x 4 c , 0 x 4 d , 0 x 4 e , 0 x 4 f , 0 x 5 0 , 0 x 5 1 , 0 x 5 2 , 0 x f f , 0 x 5 3 , 0 x 5 4 , 0 x f f "  
         a r r T a b l e   =   S p l i t ( s T a b l e , " , " )  
         l T o t a l   =   0   :   p o w 8 5   =   1  
         F o r   i   =   0   T o   1 9  
                 f F a i l e d   =   T r u e  
                 I f   i   M o d   5   =   0   T h e n  
                         l T o t a l   =   0   :   p o w 8 5   =   1  
                 E n d   I f   '   i   M o d   5   =   0  
                 i A s c   =   A s c ( M i d ( s E n c G u i d , i + 1 , 1 ) )  
                 s H e x   =   a r r T a b l e ( i A s c )  
                 I f   i A s c   > = 1 2 8   T h e n   E x i t   F o r  
                 I f   s H e x   =   " 0 x f f "   T h e n   E x i t   F o r  
                 i C h r   =   C I n t ( " & h " & R i g h t ( s H e x , 2 ) )  
                 l T o t a l   =   l T o t a l   +   ( i C h r   *   p o w 8 5 )  
                 I f   i   M o d   5   =   4   T h e n   s D e c o d e   =   s D e c o d e   &   D e c T o H e x ( l T o t a l )  
                 p o w 8 5   =   p o w 8 5   *   8 5  
                 f F a i l e d   =   F a l s e  
         N e x t   ' i  
         I f   N O T   f F a i l e d   T h e n   s G u i d   =   " { " & M i d ( s D e c o d e , 1 , 8 ) & " - " &   _  
                                                                 M i d ( s D e c o d e , 1 3 , 4 ) & " - " &   _  
                                                                 M i d ( s D e c o d e , 9 , 4 ) & " - " &   _  
                                                                 M i d ( s D e c o d e , 2 3 , 2 )   &   M i d ( s D e c o d e , 2 1 , 2 ) & " - " &   _  
                                                                 M i d ( s D e c o d e , 1 9 , 2 )   &   M i d ( s D e c o d e , 1 7 , 2 )   &   M i d ( s D e c o d e , 3 1 , 2 )   &   M i d ( s D e c o d e , 2 9 , 2 )   &   M i d ( s D e c o d e , 2 7 , 2 )   &   M i d ( s D e c o d e , 2 5 , 2 )   & " } "  
  
         G e t D e c o d e d G u i d   =   N O T   f F a i l e d  
  
 E n d   F u n c t i o n   ' G e t D e c o d e d G u i d  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e c T o H e x  
 '  
 '       C o n v e r t   a   l o n g   d e c i m a l   t o   h e x  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   D e c T o H e x ( l D e c )  
          
         D i m   s H e x  
         D i m   i L e n  
         D i m   l V a l ,   l E x p  
         D i m   a r r C h r  
      
         a r r C h r   =   A r r a y ( " 0 " , " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " , " 7 " , " 8 " , " 9 " , " A " , " B " , " C " , " D " , " E " , " F " )  
         s H e x   =   " "  
         l V a l   =   l D e c  
         l E x p   =   1 6 ^ 1 0  
         W h i l e   l E x p   > =   1  
                 I f   l V a l   > =   l E x p   T h e n  
                         s H e x   =   s H e x   &   a r r C h r ( I n t ( l V a l   /   l E x p ) )  
                         l V a l   =   l V a l   -   l E x p   *   I n t ( l V a l   /   l E x p )  
                 E l s e  
                         s H e x   =   s H e x   &   " 0 "  
                         I f   s H e x   =   " 0 "   T h e n   s H e x   =   " "  
                 E n d   I f  
                 l E x p   =   l E x p   /   1 6  
         W e n d  
  
         i L e n   =   8   -   L e n ( s H e x )  
         I f   i L e n   >   0   T h e n   s H e x   =   S t r i n g ( i L e n ,   " 0 " )   &   s H e x  
         D e c T o H e x   =   s H e x  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e l a u n c h A s 6 4 H o s t  
 '  
 '       R e l a u n c h   s e l f   w i t h   6 4   b i t   C S c r i p t   h o s t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e l a u n c h A s 6 4 H o s t  
         D i m   A r g u m e n t ,   s C m d  
  
         s C m d   =   R e p l a c e ( L C a s e ( w s c r i p t . P a t h ) ,   " s y s w o w 6 4 " ,   " s y s n a t i v e " )   &   " \ c s c r i p t . e x e   "   &   C h r ( 3 4 )   &   W S c r i p t . s c r i p t F u l l N a m e   &   C h r ( 3 4 )  
         I f   W s c r i p t . A r g u m e n t s . C o u n t   >   0   T h e n  
                 F o r   E a c h   A r g u m e n t   i n   W s c r i p t . A r g u m e n t s  
                         s C m d   =   s C m d     &     "   "   &   c h r ( 3 4 )   &   A r g u m e n t   &   c h r ( 3 4 )  
                 N e x t   ' A r g u m e n t  
         E n d   I f  
         W s c r i p t . Q u i t   C L n g ( o W S h e l l . R u n ( s C m d ,   1 ,   T r u e ) )  
  
 E n d   S u b   ' R e l a u n c h A s 6 4 H o s t  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e l a u n c h E l e v a t e d  
 '  
 '       R e l a u n c h   t h e   s c r i p t   w i t h   e l e v a t e d   p e r m i s s i o n s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e l a u n c h E l e v a t e d  
         D i m   A r g u m e n t ,   P r o c e s s ,   P r o c e s s e s  
         D i m   i P a r e n t P r o c e s s I d ,   i S p a w n e d P r o c e s s I d  
         D i m   s C m d L i n e ,   s R e t V a l F i l e ,   s V a l u e  
         D i m   o S h e l l  
  
         S e t E r r o r   E R R O R _ R E L A U N C H  
         '   S h e l l   o b j e c t   f o r   r e l a u n c h  
         S e t   o S h e l l   =   C r e a t e O b j e c t ( " S h e l l . A p p l i c a t i o n " )  
         '   b u i l d   c o m m a n d   l i n e   f o r   r e l a u n c h  
         s C m d L i n e   =   C h r ( 3 4 )   &   W S c r i p t . S c r i p t F u l l N a m e   &   C h r ( 3 4 )  
         I f   W s c r i p t . A r g u m e n t s . C o u n t   >   0   T h e n  
                 F o r   E a c h   A r g u m e n t   i n   W s c r i p t . A r g u m e n t s  
                         S e l e c t   C a s e   U C a s e ( A r g u m e n t )  
                         C a s e   " / Q " , " / Q U I E T "  
                                 ' D o n ' t   t r y   t o   r e l a u n c h   i n   q u i e t   m o d e  
                                 E x i t   S u b  
                                 S e t E r r o r   E R R O R _ E L E V A T I O N _ F A I L E D  
                         C a s e   " U A C "  
                                 ' A l r e a d y   t r i e d   e l e v a t e d   r e l a u n c h  
                                 S e t E r r o r   E R R O R _ E L E V A T I O N _ F A I L E D  
                                 E x i t   S u b  
                         C a s e   E l s e  
                                 s C m d L i n e   =   s C m d L i n e     &     "   "   &   c h r ( 3 4 )   &   A r g u m e n t   &   c h r ( 3 4 )  
                         E n d   S e l e c t  
                 N e x t   ' A r g u m e n t  
         E n d   I f  
         '   p r e p   w o r k   t o   g e t   t h e   r e t u r n   v a l u e   f r o m   t h e   e l e v a t e d   p r o c e s s  
         i P a r e n t P r o c e s s I d   =   G e t M y P r o c e s s I d    
          
 '         '   m a k e   u s e r   a w a r e   o f   e l e v a t i o n   a t t e m p t   a f t e r   r e b o o t  
 '         I f   R e g R e a d V a l u e ( H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l e a n C 2 R " ,   " R e r u n " ,   s V a l u e ,   " R E G _ D W O R D " )   T h e n  
 '                 o W S h e l l . P o p u p   " S y s t e m   r e b o o t   c o m p l e t e .   O f f S c r u b   w i l l   n o w   p r o m p t   f o r   e l e v a t i o n ! " ,   1 0 ,   S C R I P T N A M E   &   "   -   N O T E ! "  
 '         E n d   I f  
          
         '   l a u n c h   t h e   e l e v a t e d   i n s t a n c e  
         o S h e l l . S h e l l E x e c u t e   " c s c r i p t . e x e " ,   s C m d L i n e   &   "   / N o E l e v a t e   U A C " ,   " " ,   " r u n a s " ,   1  
         '   g e t   t h e   p r o c e s s   i d   o f   t h e   s p a w n e d   i n s t a n c e  
         W S c r i p t . S l e e p   5 0 0  
         S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W H E R E   P a r e n t P r o c e s s I d = ' "   &   i P a r e n t P r o c e s s I d   &   " ' " )  
         I f   P r o c e s s e s . C o u n t   >   0   T h e n  
                 F o r   E a c h   P r o c e s s   i n   P r o c e s s e s  
 	 	         i S p a w n e d P r o c e s s I d   =   P r o c e s s . P r o c e s s I d  
 	 	         E x i t   F o r  
                 N e x t   ' P r o c e s s  
                 '   m o n i t o r   t h e   t a s k l i s t   t o   d e t e c t   t h e   e n d   o f   t h e   s p a w n e d   p r o c e s s  
                 W h i l e   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W H E R E   P r o c e s s I d = ' "   &   i S p a w n e d P r o c e s s I d   &   " ' " ) . C o u n t   >   0  
                         W S c r i p t . S l e e p   3 0 0 0  
                 W e n d  
                 '   g e t   t h e   r e t u r n   v a l u e   f r o m   t h e   f i l e  
                 W s c r i p t . Q u i t   G e t R e t V a l F r o m F i l e  
         E n d   I f  
         '   e l e v a t i o n   f a i l e d   ( u s e r   d e c l i n e d )  
         S e t E r r o r   E R R O R _ E L E V A T I O N _ U S E R D E C L I N E D  
 E n d   S u b   ' R e l a u n c h E l e v a t e d  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e l a u n c h A s C S c r i p t  
 '  
 '       R e l a u n c h   s e l f   w i t h   C s c r i p t   a s   h o s t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e l a u n c h A s C S c r i p t  
         D i m   A r g u m e n t  
         D i m   s C m d L i n e  
          
         S e t E r r o r   E R R O R _ R E L A U N C H  
         s C m d L i n e   =   " c m d . e x e   / c   "   &   W S c r i p t . P a t h   &   " \ c s c r i p t . e x e   / / N O L O G O   "   &   C h r ( 3 4 )   &   W S c r i p t . s c r i p t F u l l N a m e   &   C h r ( 3 4 )  
         I f   W s c r i p t . A r g u m e n t s . C o u n t   >   0   T h e n  
                 F o r   E a c h   A r g u m e n t   i n   W s c r i p t . A r g u m e n t s  
                         s C m d L i n e   =   s C m d L i n e     &     "   "   &   c h r ( 3 4 )   &   A r g u m e n t   &   c h r ( 3 4 )  
                 N e x t   ' A r g u m e n t  
         E n d   I f  
          
         W s c r i p t . Q u i t   C L n g ( o W S h e l l . R u n ( s C m d L i n e ,   1 ,   T r u e ) )  
 E n d   S u b   ' R e l a u n c h A s C S c r i p t  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S e t E r r o r  
 '  
 '       S e t   e r r o r   b i t ( s )    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S e t E r r o r ( E r r o r B i t )  
         i E r r o r   =   i E r r o r   O R   E r r o r B i t  
         S e l e c t   C a s e   E r r o r B i t  
         C a s e   E R R O R _ D C A F _ F A I L U R E ,   E R R O R _ S T A G E 2 ,   E R R O R _ E L E V A T I O N _ U S E R D E C L I N E D ,   E R R O R _ E L E V A T I O N ,   E R R O R _ S C R I P T I N I T  
                 i E r r o r   =   i E r r o r   O R   E R R O R _ F A I L  
         E n d   S e l e c t  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C l e a r E r r o r  
 '  
 '       U n s e t   e r r o r   b i t ( s )    
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C l e a r E r r o r ( E r r o r B i t )  
         i E r r o r   =   i E r r o r   A N D   ( E R R O R _ A L L   -   E r r o r B i t )  
         S e l e c t   C a s e   E r r o r B i t  
         C a s e   E R R O R _ E L E V A T I O N _ U S E R D E C L I N E D ,   E R R O R _ E L E V A T I O N ,   E R R O R _ S C R I P T I N I T  
                 i E r r o r   =   i E r r o r   A N D   ( E R R O R _ A L L   -   E R R O R _ F A I L )  
         E n d   S e l e c t  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S e t R e t V a l  
 '  
 '       W r i t e   r e t u r n   v a l u e   t o   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S e t R e t V a l ( i E r r o r )  
         D i m   R e t V a l F i l e S t r e a m  
          
         ' d o n ' t   f a i l   s c r i p t   e x e c u t i o n   i f   w r i t i n g   t h e   r e t u r n   v a l u e   t o   f i l e   f a i l s  
         O n   E r r o r   R e s u m e   N e x t    
  
         S e t   R e t V a l F i l e S t r e a m   =   o F s o . c r e a t e T e x t F i l e ( s S c r u b D i r   &   " \ "   &   R E T V A L F I L E ,   T r u e ,   T r u e )  
         R e t V a l F i l e S t r e a m . W r i t e   i E r r o r  
         R e t V a l F i l e S t r e a m . C l o s e  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' S e t R e t V a l  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       G e t R e t V a l F r o m F i l e  
 '  
 '       R e a d   r e t u r n   v a l u e   f r o m   f i l e .  
 '       U s e d   t o   e n s u r e   r e t u r n   v a l u e   c a n   g e t   o b t a i n e d   f r o m   a n   e l e v a t e d   p r o c e s s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   G e t R e t V a l F r o m F i l e   ( )  
         D i m   R e t V a l F i l e S t r e a m  
         D i m   i R e t V a l F r o m F i l e  
  
         O n   E r r o r   R e s u m e   N e x t   ' d o n ' t   f a i l   s c r i p t   e x e c u t i o n   w h e n   g e t t i n g   t h e   r e t u r n   v a l u e   f r o m   f i l e   f a i l s  
  
         I f   o F s o . F i l e E x i s t s ( s S c r u b D i r   &   " \ "   &   R E T V A L F I L E )   T h e n  
                 S e t   R e t V a l F i l e S t r e a m   =   o F s o . O p e n T e x t F i l e ( s S c r u b D i r   &   " \ "   &   R E T V A L F I L E ,   1 ,   F a l s e ,   - 2 )  
                 G e t R e t V a l F r o m F i l e   =   R e t V a l F i l e S t r e a m . R e a d A l l  
                 R e t V a l F i l e S t r e a m . C l o s e  
                 E x i t   F u n c t i o n  
         E n d   I f  
         E r r . C l e a r  
         O n   E r r o r   G o t o   0  
         G e t R e t V a l F r o m F i l e   =   E R R O R _ U N K N O W N  
 E n d   F u n c t i o n   ' G e t R e t V a l F r o m F i l e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C r e a t e L o g  
 '  
 '       C r e a t e   t h e   r e m o v a l   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C r e a t e L o g  
         D i m   D a t e T i m e  
         D i m   s L o g N a m e  
          
         O n   E r r o r   R e s u m e   N e x t  
         '   c r e a t e   t h e   l o g   f i l e  
         S e t   D a t e T i m e   =   C r e a t e O b j e c t ( " W b e m S c r i p t i n g . S W b e m D a t e T i m e " )  
         D a t e T i m e . S e t V a r D a t e   N o w ,   T r u e  
         s L o g N a m e   =   s L o g D i r   &   " \ "   &   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % C O M P U T E R N A M E % " )  
         s L o g N a m e   =   s L o g N a m e   &     " _ "   &   L e f t ( D a t e T i m e . V a l u e ,   1 4 )  
         s L o g N a m e   =   s L o g N a m e   &   " _ S c r u b L o g . t x t "  
         E r r . C l e a r  
         S e t   L o g S t r e a m   =   o F s o . C r e a t e T e x t F i l e ( s L o g N a m e ,   T r u e ,   T r u e )  
         I f   E r r   < >   0   T h e n    
                 E r r . C l e a r  
                 s L o g D i r   =   s S c r u b D i r  
                 s L o g N a m e   =   s L o g D i r   &   " \ "   &   o W S h e l l . E x p a n d E n v i r o n m e n t S t r i n g s ( " % C O M P U T E R N A M E % " )  
                 s L o g N a m e   =   s L o g N a m e   &     " _ "   &   L e f t ( D a t e T i m e . V a l u e ,   1 4 )  
                 s L o g N a m e   =   s L o g N a m e   &   " _ S c r u b L o g . t x t "  
                 S e t   L o g S t r e a m   =   o F s o . C r e a t e T e x t F i l e ( s L o g N a m e ,   T r u e ,   T r u e )  
         E n d   I f  
         O n   E r r o r   G o t o   0  
  
         L o g   " M i c r o s o f t   C u s t o m e r   S u p p o r t   S e r v i c e s   -   "   &   O N A M E   &   "   R e m o v a l   U t i l i t y "   &   v b C r L f   & _  
                 " R e m o v e s   " &   O N A M E   &   "   w h e n   a   r e g u l a r   u n i n s t a l l   i s   n o   l o n g e r   p o s s i b l e . "   &   v b C r L f   &   v b C r L f   &   _  
                 " V e r s i o n :   "   &   v b T a b   &   S C R I P T V E R S I O N   &   v b C r L f   &   _  
                 " 6 4   b i t   O S :   "   &   v b T a b   &   f 6 4   &   v b C r L f   &   _  
                 " R e m o v a l   s t a r t :   "   &   v b T a b   &   T i m e   &   v b C r L f  
         f L o g I n i t i a l i z e d   =   T r u e  
 E n d   S u b   ' C r e a t e L o g  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       H i v e S t r i n g  
 '  
 '       T r a n s l a t e s   t h e   n u m e r i c   c o n s t a n t   i n t o   t h e   h u m a n   r e a d a b l e   r e g i s t r y   h i v e   s t r i n g  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   H i v e S t r i n g ( h D e f K e y )  
         S e l e c t   C a s e   h D e f K e y  
                 C a s e   H K C R   :   H i v e S t r i n g   =   " H K E Y _ C L A S S E S _ R O O T "  
                 C a s e   H K C U   :   H i v e S t r i n g   =   " H K E Y _ C U R R E N T _ U S E R "  
                 C a s e   H K L M   :   H i v e S t r i n g   =   " H K E Y _ L O C A L _ M A C H I N E "  
                 C a s e   H K U     :   H i v e S t r i n g   =   " H K E Y _ U S E R S "  
                 C a s e   E l s e   :   H i v e S t r i n g   =   h D e f K e y  
         E n d   S e l e c t  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g K e y E x i s t s  
 '  
 '       R e t u r n s   a   b o o l e a n   f o r   t h e   t e s t   o n   e x i s t e n c e   o f   a   g i v e n   r e g i s t r y   k e y  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e g K e y E x i s t s ( h D e f K e y ,   s S u b K e y N a m e )  
         D i m   a r r K e y s  
         R e g K e y E x i s t s   =   F a l s e  
         I f   o R e g . E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )   =   0   T h e n   R e g K e y E x i s t s   =   T r u e  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g V a l E x i s t s  
 '  
 '       R e t u r n s   a   b o o l e a n   f o r   t h e   t e s t   o n   e x i s t e n c e   o f   a   g i v e n   r e g i s t r y   v a l u e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e g V a l E x i s t s ( h D e f K e y , s S u b K e y N a m e , s N a m e )  
         D i m   a r r V a l u e T y p e s ,   a r r V a l u e N a m e s  
         D i m   i  
  
         R e g V a l E x i s t s   =   F a l s e  
         I f   N o t   R e g K e y E x i s t s ( h D e f K e y , s S u b K e y N a m e )   T h e n   E x i t   F u n c t i o n  
         I f   o R e g . E n u m V a l u e s ( h D e f K e y , s S u b K e y N a m e , a r r V a l u e N a m e s , a r r V a l u e T y p e s )   =   0   A N D   I s A r r a y ( a r r V a l u e N a m e s )   T h e n  
                 F o r   i   =   0   T o   U B o u n d ( a r r V a l u e N a m e s )    
                         I f   L C a s e ( a r r V a l u e N a m e s ( i ) )   =   T r i m ( L C a s e ( s N a m e ) )   T h e n   R e g V a l E x i s t s   =   T r u e  
                 N e x t    
         E n d   I f   ' o R e g . E n u m V a l u e s  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g R e a d V a l u e  
 '  
 '       R e a d   t h e   v a l u e   o f   a   g i v e n   r e g i s t r y   e n t r y  
 '       T h e   c o r r e c t   t y p e   h a s   t o   b e   p a s s e d   i n   a s   a r g u m e n t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e g R e a d V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   s V a l u e ,   s T y p e )  
         D i m   R e t V a l  
         D i m   I t e m  
         D i m   a r r V a l u e s  
          
         S e l e c t   C a s e   U C a s e ( s T y p e )  
                 C a s e   " 1 " ,   " R E G _ S Z "  
                         R e t V a l   =   o R e g . G e t S t r i n g V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   s V a l u e )  
                         I f   N o t   R e t V a l   =   0   A N D   f 6 4   T h e n   R e t V a l   =   o R e g . G e t S t r i n g V a l u e ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e ,   s V a l u e )  
                 C a s e   " 2 " ,   " R E G _ E X P A N D _ S Z "  
                         R e t V a l   =   o R e g . G e t E x p a n d e d S t r i n g V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   s V a l u e )  
                         I f   N O T   R e t V a l   =   0   A N D   f 6 4   T h e n   R e t V a l   =   o R e g . G e t E x p a n d e d S t r i n g V a l u e ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e ,   s V a l u e )  
                 C a s e   " 3 " ,   " R E G _ B I N A R Y "  
                         R e t V a l   =   o R e g . G e t B i n a r y V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   s V a l u e )  
                         I f   N O T   R e t V a l   =   0   A N D   f 6 4   T h e n   R e t V a l   =   o R e g . G e t B i n a r y V a l u e ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e ,   s V a l u e )  
                 C a s e   " 4 " ,   " R E G _ D W O R D "  
                         R e t V a l   =   o R e g . G e t D W O R D V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   s V a l u e )  
                         I f   N O T   R e t V a l   =   0   A N D   f 6 4   T h e n   R e t V a l   =   o R e g . G e t D W O R D V a l u e ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e ,   s V a l u e )  
                 C a s e   " 7 " ,   " R E G _ M U L T I _ S Z "  
                         R e t V a l   =   o R e g . G e t M u l t i S t r i n g V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   a r r V a l u e s )  
                         I f   N O T   R e t V a l   =   0   A N D   f 6 4   T h e n   R e t V a l   =   o R e g . G e t M u l t i S t r i n g V a l u e ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e ,   a r r V a l u e s )  
                         I f   R e t V a l   =   0   T h e n   s V a l u e   =   J o i n ( a r r V a l u e s ,   c h r ( 1 3 ) )  
                 C a s e   E l s e  
                         R e t V a l   =   - 1  
         E n d   S e l e c t   ' s V a l u e  
          
         R e g R e a d V a l u e   =   ( R e t V a l   =   0 )  
 E n d   F u n c t i o n   ' R e g R e a d V a l u e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g E n u m V a l u e s  
 '  
 '       E n u m e r a t e   a   r e g i s t r y   k e y   t o   r e t u r n   a l l   v a l u e s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e g E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s )  
         D i m   R e t V a l ,   R e t V a l 6 4  
         D i m   a r r N a m e s 3 2 ,   a r r N a m e s 6 4 ,   a r r T y p e s 3 2 ,   a r r T y p e s 6 4  
          
         I f   f 6 4   T h e n  
                 R e t V a l   =   o R e g . E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e ,   a r r N a m e s 3 2 ,   a r r T y p e s 3 2 )  
                 R e t V a l 6 4   =   o R e g . E n u m V a l u e s ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   a r r N a m e s 6 4 ,   a r r T y p e s 6 4 )  
                 I f   ( R e t V a l   =   0 )   A N D   ( N O T   R e t V a l 6 4   =   0 )   A N D   I s A r r a y ( a r r N a m e s 3 2 )   A N D   I s A r r a y ( a r r T y p e s 3 2 )   T h e n    
                         a r r N a m e s   =   a r r N a m e s 3 2  
                         a r r T y p e s   =   a r r T y p e s 3 2  
                 E n d   I f  
                 I f   ( N O T   R e t V a l   =   0 )   A N D   ( R e t V a l 6 4   =   0 )   A N D   I s A r r a y ( a r r N a m e s 6 4 )   A N D   I s A r r a y ( a r r T y p e s 6 4 )   T h e n    
                         a r r N a m e s   =   a r r N a m e s 6 4  
                         a r r T y p e s   =   a r r T y p e s 6 4  
                 E n d   I f  
                 I f   ( R e t V a l   =   0 )   A N D   ( R e t V a l 6 4   =   0 )   A N D   I s A r r a y ( a r r N a m e s 3 2 )   A N D   I s A r r a y ( a r r N a m e s 6 4 )   A N D   I s A r r a y ( a r r T y p e s 3 2 )   A N D   I s A r r a y ( a r r T y p e s 6 4 )   T h e n    
                         a r r N a m e s   =   R e m o v e D u p l i c a t e s ( S p l i t ( ( J o i n ( a r r N a m e s 3 2 ,   " \ " )   &   " \ "   &   J o i n ( a r r N a m e s 6 4 ,   " \ " ) ) ,   " \ " ) )  
                         a r r T y p e s   =   R e m o v e D u p l i c a t e s ( S p l i t ( ( J o i n ( a r r T y p e s 3 2 ,   " \ " )   &   " \ "   &   J o i n ( a r r T y p e s 6 4 ,   " \ " ) ) ,   " \ " ) )  
                 E n d   I f  
         E l s e  
                 R e t V a l   =   o R e g . E n u m V a l u e s ( h D e f K e y ,   s S u b K e y N a m e ,   a r r N a m e s ,   a r r T y p e s )  
         E n d   I f   ' f 6 4  
         R e g E n u m V a l u e s   =   ( ( R e t V a l   =   0 )   O R   ( R e t V a l 6 4   =   0 ) )   A N D   I s A r r a y ( a r r N a m e s )   A N D   I s A r r a y ( a r r T y p e s )  
 E n d   F u n c t i o n   ' R e g E n u m V a l u e s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g E n u m K e y  
 '  
 '       E n u m e r a t e   a   r e g i s t r y   k e y   t o   r e t u r n   a l l   s u b k e y s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e g E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )  
         D i m   R e t V a l ,   R e t V a l 6 4  
         D i m   a r r K e y s 3 2 ,   a r r K e y s 6 4  
          
         I f   f 6 4   T h e n  
                 R e t V a l   =   o R e g . E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s 3 2 )  
                 R e t V a l 6 4   =   o R e g . E n u m K e y ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   a r r K e y s 6 4 )  
                 I f   ( R e t V a l   =   0 )   A N D   ( N O T   R e t V a l 6 4   =   0 )   A N D   I s A r r a y ( a r r K e y s 3 2 )   T h e n   a r r K e y s   =   a r r K e y s 3 2  
                 I f   ( N o t   R e t V a l   =   0 )   A N D   ( R e t V a l 6 4   =   0 )   A N D   I s A r r a y ( a r r K e y s 6 4 )   T h e n   a r r K e y s   =   a r r K e y s 6 4  
                 I f   ( R e t V a l   =   0 )   A N D   ( R e t V a l 6 4   =   0 )   T h e n    
                         I f   I s A r r a y ( a r r K e y s 3 2 )   A N D   I s A r r a y   ( a r r K e y s 6 4 )   T h e n    
                                 a r r K e y s   =   R e m o v e D u p l i c a t e s ( S p l i t ( ( J o i n ( a r r K e y s 3 2 ,   " \ " )   &   " \ "   &   J o i n ( a r r K e y s 6 4 ,   " \ " ) ) ,   " \ " ) )  
                         E l s e I f   I s A r r a y ( a r r K e y s 6 4 )   T h e n  
                                 a r r K e y s   =   a r r K e y s 6 4  
                         E l s e  
                                 a r r K e y s   =   a r r K e y s 3 2  
                         E n d   I f  
                 E n d   I f  
         E l s e  
                 R e t V a l   =   o R e g . E n u m K e y ( h D e f K e y ,   s S u b K e y N a m e ,   a r r K e y s )  
         E n d   I f   ' f 6 4  
         R e g E n u m K e y   =   ( ( R e t V a l   =   0 )   O R   ( R e t V a l 6 4   =   0 ) )   A N D   I s A r r a y ( a r r K e y s )  
 E n d   F u n c t i o n   ' R e g E n u m K e y  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g D e l e t e V a l u e  
 '  
 '       W r a p p e r   a r o u n d   o R e g . D e l e t e V a l u e   t o   h a n d l e   6 4   b i t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e g D e l e t e V a l u e ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e ,   f R e g M u l t i S Z )  
         D i m   s D e l K e y N a m e ,   s V a l u e  
         D i m   i R e t V a l  
         D i m   f K e e p  
          
         '   e n s u r e   t r a i l i n g   " \ "  
         s S u b K e y N a m e   =   s S u b K e y N a m e   &   " \ "  
         W h i l e   I n S t r ( s S u b K e y N a m e ,   " \ \ " )   >   0  
                 s S u b K e y N a m e   =   R e p l a c e ( s S u b K e y N a m e ,   " \ \ " ,   " \ " )  
         W e n d  
  
         f K e e p   =   d i c K e e p R e g . E x i s t s ( L C a s e ( s S u b K e y N a m e   &   s N a m e ) )  
         I f   ( N O T   f K e e p   A N D   f 6 4 )   T h e n   f K e e p   =   d i c K e e p R e g . E x i s t s ( L C a s e ( W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e )   &   s N a m e ) )  
         I f   f K e e p   T h e n  
                 L o g O n l y   " D i s a l l o w i n g   t h e   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e   &   s N a m e  
                 I f   N O T   f F o r c e   T h e n   E x i t   S u b  
         E n d   I f  
          
         '   c h e c k   o n   f o r c e d   d e l e t e  
         I f   f K e e p   T h e n  
                 L o g O n l y   " E n f o r c e d   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e   &   s N a m e  
                 L o g O n l y   "       R e m a i n i n g   a p p l i c a t i o n s   w i l l   n e e d   a   r e p a i r ! "  
         E n d   I f  
          
         '   e n s u r e   v a l u e   e x i s t s  
         I f   R e g V a l E x i s t s ( h D e f K e y ,   s S u b K e y N a m e ,   s N a m e )   T h e n  
                 s D e l K e y N a m e   =   s S u b K e y N a m e  
         E l s e I f   R e g V a l E x i s t s ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ,   s N a m e )   T h e n  
                 s D e l K e y N a m e   =     W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e )  
         E l s e  
                 L o g O n l y   " V a l u e   n o t   f o u n d .   C a n n o t   d e l e t e   v a l u e :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e   &   s N a m e  
                 E x i t   S u b  
         E n d   I f  
  
         '   p r e v e n t   u n i n t e n t i o n a l ,   u n s a f e   R E G _ M U L T I _ S Z   d e l e t e  
         I f   R e g R e a d V a l u e ( h D e f K e y ,   s D e l K e y N a m e ,   s N a m e ,   s V a l u e ,   " R E G _ M U L T I _ S Z " )   A N D   N O T   f R e g M u l t i S Z   T h e n  
                 L o g O n l y   " D i s a l l o w i n g   u n s a f e   d e l e t e   o f   R E G _ M U L T I _ S Z :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s D e l K e y N a m e   &   s N a m e  
                 E x i t   S u b  
         E n d   I f  
          
         '   e x e c u t e   d e l e t e   o p e r a t i o n  
         I f   N o t   f D e t e c t O n l y   T h e n    
                 L o g O n l y   " D e l e t e   r e g i s t r y   v a l u e :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s D e l K e y N a m e   &   "   - >   "   &   s N a m e  
                 i R e t V a l   =   0  
                 i R e t V a l   =   o R e g . D e l e t e V a l u e ( h D e f K e y ,   s D e l K e y N a m e ,   s N a m e )  
                 C h e c k E r r o r   " R e g D e l e t e V a l u e "  
                 I f   N O T   ( i R e t V a l   =   0 )   T h e n  
                         L o g O n l y   "           D e l e t e   f a i l e d .   R e t u r n   v a l u e :   "   &   i R e t V a l  
                         S e t E r r o r   E R R O R _ S T A G E 2  
                 E n d   I f  
         E l s e  
                 L o g O n l y   " P r e v i e w   m o d e .   D i s a l l o w i n g   d e l e t e   r e g i s t r y   v a l u e :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s D e l K e y N a m e   &   "   - >   "   &   s N a m e  
         E n d   I f  
         O n   E r r o r   G o t o   0  
  
 E n d   S u b   ' R e g D e l e t e V a l u e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g D e l e t e K e y  
 '  
 '       W r a p p p e r   a r o u n d   R e g D e l e t e K e y E x   t o   h a n d l e   6 4 b i t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e g D e l e t e K e y ( h D e f K e y ,   s S u b K e y N a m e )  
         D i m   s D e l K e y N a m e  
         D i m   f K e e p  
          
         '   e n s u r e   t r a i l i n g   " \ "  
         s S u b K e y N a m e   =   s S u b K e y N a m e   &   " \ "  
         W h i l e   I n S t r ( s S u b K e y N a m e ,   " \ \ " )   >   0  
                 s S u b K e y N a m e   =   R e p l a c e ( s S u b K e y N a m e ,   " \ \ " ,   " \ " )  
         W e n d  
  
         f K e e p   =   d i c K e e p R e g . E x i s t s ( L C a s e ( s S u b K e y N a m e ) )  
         I f   ( N O T   f K e e p   A N D   f 6 4 )   T h e n   f K e e p   =   d i c K e e p R e g . E x i s t s ( L C a s e ( W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) ) )  
         I f   f K e e p   T h e n  
                 L o g O n l y   " D i s a l l o w i n g   t h e   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e  
                 I f   N O T   f F o r c e   T h e n   E x i t   S u b  
         E n d   I f  
          
         '   c h e c k   o n   f o r c e d   d e l e t e  
         I f   f K e e p   T h e n  
                 L o g O n l y   " E n f o r c e d   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e  
                 L o g O n l y   "       R e m a i n i n g   a p p l i c a t i o n s   w i l l   n e e d   a   r e p a i r ! "  
         E n d   I f  
          
         I f   L e n ( s S u b K e y N a m e )   >   1   T h e n  
                 ' S t r i p   o f   t r a i l i n g   " \ "  
                 s S u b K e y N a m e   =   L e f t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   1 )  
         E n d   I f  
          
         '   e n s u r e   k e y   e x i s t s  
         I f   R e g K e y E x i s t s ( h D e f K e y ,   s S u b K e y N a m e )   T h e n  
                 s D e l K e y N a m e   =   s S u b K e y N a m e  
         E l s e I f   f 6 4   A N D   R e g K e y E x i s t s ( h D e f K e y ,   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e ) )   T h e n  
                 s D e l K e y N a m e   =   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e )  
         E l s e  
                 L o g O n l y   " K e y   n o t   f o u n d .   C a n n o t   d e l e t e   k e y :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e  
                 E x i t   S u b  
         E n d   I f  
  
         '   e x e c u t e   d e l e t e  
         I f   N o t   f D e t e c t O n l y   T h e n  
                 L o g O n l y   " D e l e t e   r e g i s t r y   k e y :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s D e l K e y N a m e  
                 O n   E r r o r   R e s u m e   N e x t  
                 R e g D e l e t e K e y E x   h D e f K e y ,   s D e l K e y N a m e  
                 O n   E r r o r   G o t o   0  
         E l s e  
                 L o g O n l y   " P r e v i e w   m o d e .   D i s a l l o w i n g   d e l e t e   o f   r e g i s t r y   k e y :   "   &   H i v e S t r i n g ( h D e f K e y )   &   " \ "   &   s S u b K e y N a m e  
         E n d   I f  
 E n d   S u b   ' R e g D e l e t e K e y  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e g D e l e t e K e y E x  
 '  
 '       R e c u r s i v e l y   d e l e t e   a   r e g i s t r y   s t r u c t u r e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e g D e l e t e K e y E x ( h D e f K e y ,   s S u b K e y N a m e )    
         D i m   a r r S u b k e y s  
         D i m   s S u b k e y  
         D i m   i R e t V a l  
  
         ' S t r i p   o f   t r a i l i n g   " \ "  
         I f   L e n ( s S u b K e y N a m e )   >   1   T h e n  
                 I f   R i g h t ( s S u b K e y N a m e ,   1 )   =   " \ "   T h e n   s S u b K e y N a m e   =   L e f t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   1 )  
         E n d   I f  
         O n   E r r o r   R e s u m e   N e x t  
  
         '   e x c e p t i o n   h a n d l e r  
         I f   ( h D e f K e y   =   H K L M )   A N D   ( s S u b K e y N a m e   =   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n " )   T h e n  
                 i R e t V a l   =   o W S h e l l . R u n ( " r e g   d e l e t e   H K L M \ S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l i c k T o R u n   / f " ,   0 ,   T r u e )  
                 E x i t   S u b  
         E n d   I f  
  
         '   r e g u l a r   r e c u r s i o n  
         o R e g . E n u m K e y   h D e f K e y ,   s S u b K e y N a m e ,   a r r S u b k e y s  
         I f   I s A r r a y ( a r r S u b k e y s )   T h e n    
                 F o r   E a c h   s S u b k e y   I n   a r r S u b k e y s    
                         R e g D e l e t e K e y E x   h D e f K e y ,   s S u b K e y N a m e   &   " \ "   &   s S u b k e y    
                 N e x t    
         E n d   I f    
         I f   N o t   f D e t e c t O n l y   T h e n    
                 i R e t V a l   =   0  
                 i R e t V a l   =   o R e g . D e l e t e K e y ( h D e f K e y ,   s S u b K e y N a m e )  
                 I f   N O T   ( i R e t V a l   =   0 )   T h e n   L o g O n l y   "           D e l e t e   f a i l e d .   R e t u r n   v a l u e :   " & i R e t V a l  
         E n d   I f  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' R e g D e l e t e K e y E x  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       W o w 6 4 K e y  
 '  
 '       R e t u r n   t h e   3 2 b i t   r e g k e y   l o c a t i o n   o n   a   6 4 b i t   e n v i r o n m e n t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   W o w 6 4 K e y ( h D e f K e y ,   s S u b K e y N a m e )  
         D i m   i P o s  
  
         S e l e c t   C a s e   h D e f K e y  
         C a s e   H K C U  
                 I f   L e f t ( s S u b K e y N a m e ,   1 7 )   =   " S o f t w a r e \ C l a s s e s \ "   T h e n  
                         W o w 6 4 K e y   =   L e f t ( s S u b K e y N a m e ,   1 7 )   &   " W o w 6 4 3 2 N o d e \ "   &   R i g h t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   1 7 )  
                 E l s e  
                         i P o s   =   I n S t r ( s S u b K e y N a m e ,   " \ " )  
                         W o w 6 4 K e y   =   L e f t ( s S u b K e y N a m e ,   i P o s )   &   " W o w 6 4 3 2 N o d e \ "   &   R i g h t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   i P o s )  
                 E n d   I f  
         C a s e   H K L M  
                 I f   L e f t ( s S u b K e y N a m e ,   1 7 )   =   " S o f t w a r e \ C l a s s e s \ "   T h e n  
                         W o w 6 4 K e y   =   L e f t ( s S u b K e y N a m e ,   1 7 )   &   " W o w 6 4 3 2 N o d e \ "   &   R i g h t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   1 7 )  
                 E l s e  
                         i P o s   =   I n S t r ( s S u b K e y N a m e ,   " \ " )  
                         W o w 6 4 K e y   =   L e f t ( s S u b K e y N a m e ,   i P o s )   &   " W o w 6 4 3 2 N o d e \ "   &   R i g h t ( s S u b K e y N a m e ,   L e n ( s S u b K e y N a m e )   -   i P o s )  
                 E n d   I f  
         C a s e   E l s e  
                 W o w 6 4 K e y   =   " W o w 6 4 3 2 N o d e \ "   &   s S u b K e y N a m e  
         E n d   S e l e c t   ' h D e f K e y  
 E n d   F u n c t i o n   ' W o w 6 4 K e y  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e m o v e D u p l i c a t e s  
 '  
 '       R e m o v e   d u p l i c a t e   e n t r i e s   f r o m   a   o n e   d i m e n s i o n a l   a r r a y  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   R e m o v e D u p l i c a t e s ( A r r a y )  
         D i m   I t e m  
         D i m   d i c N o D u p e s  
          
         S e t   d i c N o D u p e s   =   C r e a t e O b j e c t ( " S c r i p t i n g . D i c t i o n a r y " )  
         F o r   E a c h   I t e m   i n   A r r a y  
                 I f   N o t   d i c N o D u p e s . E x i s t s ( I t e m )   T h e n   d i c N o D u p e s . A d d   I t e m , I t e m  
         N e x t   ' I t e m  
         R e m o v e D u p l i c a t e s   =   d i c N o D u p e s . K e y s  
 E n d   F u n c t i o n   ' R e m o v e D u p l i c a t e s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C h e c k E r r o r  
 '  
 '       C h e c k s   t h e   s t a t u s   o f   ' E r r '   a n d   l o g s   t h e   e r r o r   d e t a i l s   i f   < >   0  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   C h e c k E r r o r ( s M o d u l e )  
         I f   E r r   < >   0   T h e n    
                 L o g O n l y   "       E r r o r :   "   &   s M o d u l e   &   "   -   S o u r c e :   "   &   E r r . S o u r c e   &   " ;   E r r #   ( H e x ) :   "   &   H e x (   E r r   )   &   _  
                               " ;   E r r #   ( D e c ) :   "   &   E r r   &   " ;   D e s c r i p t i o n   :   "   &   E r r . D e s c r i p t i o n  
         E n d   I f   ' E r r   =   0  
         E r r . C l e a r  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       L o g H  
 '  
 '       W r i t e   a   h e a d e r   l o g   s t r i n g   t o   t h e   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   L o g H   ( s L o g )  
         L o g S t r e a m . W r i t e L i n e   " "  
         s L o g   =   s L o g   &   v b C r L f   &   S t r i n g ( L e n ( s L o g ) ,   " = " )  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   " "  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   s L o g  
         L o g S t r e a m . W r i t e L i n e   s L o g  
 E n d   S u b   ' L o g h  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       L o g H 1  
 '  
 '       W r i t e   a   h e a d e r   l o g   s t r i n g   t o   t h e   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   L o g H 1   ( s L o g )  
         L o g S t r e a m . W r i t e L i n e   " "  
         s L o g   =   s L o g   &   v b C r L f   &   S t r i n g ( L e n ( s L o g ) ,   " - " )  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   " "  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   s L o g  
         L o g S t r e a m . W r i t e L i n e   s L o g  
 E n d   S u b   ' L o g H 1  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       L o g H 2  
 '  
 '       W r i t e   w / o   i n d e n t   C m d   w i n d o w   a n d   t h e   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   L o g H 2   ( s L o g )  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   s L o g  
         L o g S t r e a m . W r i t e L i n e   " "  
         L o g S t r e a m . W r i t e L i n e   s L o g  
 E n d   S u b   ' L o g H 2  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       L o g  
 '  
 '       E c h o s   t h e   l o g   s t r i n g   t o   t h e   C m d   w i n d o w   a n d   t h e   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   L o g   ( s L o g )  
         I f   N O T   f Q u i e t   A N D   f C S c r i p t   T h e n   w s c r i p t . e c h o   s L o g  
         L o g S t r e a m . W r i t e L i n e   "       "   &   T i m e   &   " :   "   &   s L o g  
 E n d   S u b   ' L o g  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       L o g O n l y  
 '  
 '       C o m m i t s   t h e   l o g   s t r i n g   t o   t h e   l o g   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   L o g O n l y   ( s L o g )  
         L o g S t r e a m . W r i t e L i n e   "       "   &   T i m e   &   " :   "   &   s L o g  
 E n d   S u b   ' L o g  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       I n S c o p e  
 '  
 '       C h e c k   i f   P r o d u c t C o d e   i s   i n   s c o p e   f o r   r e m o v a l  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 ' C h e c k   i f   P r o d u c t C o d e   i s   i n   s c o p e  
 F u n c t i o n   I n S c o p e ( s P r o d u c t C o d e )  
         D i m   f I n S c o p e  
         D i m   s P r o d  
 	  
 	 C o n s t   O F F I C E I D   =   " 0 0 0 0 0 0 0 F F 1 C E } "  
 	  
 	 O n   E r r o r   R e s u m e   N e x t  
  
         f I n S c o p e   =   F a l s e  
         I f   L e n ( s P r o d u c t C o d e )   =   3 8   T h e n  
                 s P r o d   =   U C a s e ( s P r o d u c t C o d e )  
                 I f   R i g h t ( s P r o d ,   P R O D L E N )   =   O F F I C E I D   T h e n  
                 	 I f   C I n t ( M i d ( s P r o d ,   4 ,   2 ) )   >   1 4   T h e n    
 	                         I f   E r r   < >   0   T h e n  
 	                         	 E r r . C l e a r  
 	                         	 E x i t   F u n c t i o n  
 	                         E n d   I f  
 	                         S e l e c t   C a s e   M i d ( s P r o d ,   1 1 ,   4 )  
 	                         C a s e   " 0 0 7 E " ,   " 0 0 8 F " ,   " 0 0 8 C " ,   " 2 4 E 1 " ,   " 2 3 7 A "  
 	                                 f I n S c o p e   =   T r u e  
 	                         E n d   S e l e c t  
                         E n d   I f  
                 E n d   I f  
                 '   M i c r o s o f t   O n l i n e   S e r v i c e s   S i g n - i n   A s s i s t a n t   ( x 6 4   s h i p   a n d   x 8 6   s h i p )  
                 I f   s P r o d   =   " { 6 C 1 A D E 9 7 - 2 4 E 1 - 4 A E 4 - A E D D - 8 6 D 3 A 2 0 9 C E 6 0 } "   T h e n   f I n S c o p e   =   T r u e  
                 I f   s P r o d   =   " { 9 5 2 0 D D E B - 2 3 7 A - 4 1 D B - A A 2 0 - F 2 E F 2 3 6 0 D C E B } "   T h e n   f I n S c o p e   =   T r u e  
                 I f   s P r o d   =   U C a s e ( s P a c k a g e G u i d )   T h e n   f I n S c o p e   =   T r u e  
                 I f   s P r o d   =   U C a s e ( " { 9 A C 0 8 E 9 9 - 2 3 0 B - 4 7 e 8 - 9 7 2 1 - 4 5 7 7 B 7 F 1 2 4 E A } " )   T h e n   f I n S c o p e   =   T r u e  
         E n d   I f   ' 3 8  
  
         I n S c o p e   =   f I n S c o p e  
 E n d   F u n c t i o n   ' I n S c o p e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       C h e c k D e l e t e  
 '  
 '       C h e c k   a   P r o d u c t C o d e   i s   k n o w n   t o   s t a y   i n s t a l l e d  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   C h e c k D e l e t e ( s P r o d u c t C o d e )  
  
         C h e c k D e l e t e   =   F a l s e  
         '   e n s u r e   v a l i d   G U I D   l e n g t h  
         I f   N O T   L e n ( s P r o d u c t C o d e )   =   3 8   T h e n   E x i t   F u n c t i o n  
         '   o n l y   c a r e   i f   i t ' s   i n   t h e   e x p e c t e d   P r o d u c t C o d e   p a t t e r n    
         I f   N O T   I n S c o p e ( s P r o d u c t C o d e )   T h e n   E x i t   F u n c t i o n  
         '   c h e c k   i f   i t ' s   a   k n o w n   p r o d u c t   t h a t   s h o u l d   b e   k e p t  
         I f   d i c K e e p S k u . E x i s t s ( U C a s e ( s P r o d u c t C o d e ) )   T h e n   E x i t   F u n c t i o n  
          
         C h e c k D e l e t e   =   T r u e  
 E n d   F u n c t i o n   ' C h e c k D e l e t e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l e t e S e r v i c e  
 '  
 '       D e l e t e   a   s e r v i c e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 ' D e l e t e   a   s e r v i c e  
 S u b   D e l e t e S e r v i c e ( s N a m e )  
         D i m   S e r v i c e s ,   s r v c ,   P r o c e s s e s ,   p r o c e s s  
         D i m   s Q u e r y ,   s S t a t e s ,   s P r o c e s s N a m e ,   s C m d  
         D i m   i R e t  
          
         O n   E r r o r   R e s u m e   N e x t  
          
         s S t a t e s   =   " S T A R T E D ; R U N N I N G "  
         s Q u e r y   =   " S e l e c t   *   F r o m   W i n 3 2 _ S e r v i c e   W h e r e   N a m e = ' "   &   s N a m e   &   " ' "  
         S e t   S e r v i c e s   =   o W m i L o c a l . E x e c q u e r y ( s Q u e r y )  
          
         '   s t o p   a n d   d e l e t e   t h e   s e r v i c e  
         F o r   E a c h   s r v c   i n   S e r v i c e s  
                 L o g   "       F o u n d   s e r v i c e   "   &   s N a m e   &   "   ( "   &   s r v c . D i s p l a y N a m e   &   " )   i n   s t a t e   "   &   s r v c . S t a t e  
                 '   g e t   t h e   p r o c e s s   n a m e  
                 s P r o c e s s N a m e   =   T r i m ( R e p l a c e ( M i d ( s r v c . P a t h N a m e ,   I n S t r R e v ( s r v c . P a t h N a m e , " \ " )   +   1 ) ,   c h r ( 3 4 ) ,   " " ) )  
                 '   s t o p   t h e   s e r v i c e  
                 I f   I n S t r ( s S t a t e s ,   U C a s e ( s r v c . S t a t e ) )   >   0   T h e n  
                         i R e t   =   s r v c . S t o p S e r v i c e ( )  
                         L o g O n l y   "   a t t e m p t   t o   s t o p   s e r v i c e   "   &   s N a m e   &   "   r e t u r n e d :   "   &   i R e t  
                 E n d   I f  
                 '   e n s u r e   n o   m o r e   i n s t a n c e s   o f   t h e   s e r v i c e   a r e   r u n n i n g  
                 S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W h e r e   N a m e = ' "   &   s P r o c e s s N a m e   &   " ' " )  
                 F o r   E a c h   p r o c e s s   i n   P r o c e s s e s  
                         i R e t   =   p r o c e s s . T e r m i n a t e ( )  
                 N e x t   ' P r o c e s s  
                 I f   f D e t e c t O n l y   T h e n    
                         L o g   "       N o t   d e l e t i n g   s e r v i c e   "   &   s N a m e   &   "   i n   p r e v i e w   m o d e "  
                         E x i t   S u b  
                 E n d   I f  
                 i R e t   =   s r v c . D e l e t e ( )  
                 L o g   "       D e l e t e   s e r v i c e   "   &   s N a m e   &   "   r e t u r n e d :   "   &   i R e t  
         N e x t   ' s r v c  
  
         '   c h e c k   i f   s e r v i c e   g o t   d e l e t e d  
         S e t   S e r v i c e s   =   o W m i L o c a l . E x e c q u e r y ( s Q u e r y )  
         F o r   E a c h   s r v c   i n   S e r v i c e s  
                 '   f a i l e d   t o   d e l e t e   s e r v i c e .   r e t r y   w i t h   ' s c '   c o m m a n d  
                 s L o g   "   D e l e t i n g   s e r v i c e   "   &   s N a m e   &   "   f a i l e d .   R e t r y   d e l e t e   u s i n g   ' S C '   c o m m a n d "  
                 s C m d   =   " s c   d e l e t e   "   &   s N a m e  
                 i R e t   =   o W S h e l l . R u n ( s C m d ,   0 ,   T r u e )  
         N e x t   ' s r v c  
  
         S e t   S e r v i c e s   =   N o t h i n g  
         E r r . C l e a r  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' D e l e t e S e r v i c e  
  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S e t u p R e t V a l  
 '  
 '       T r a n s l a t i o n   f o r   k n o w n   u n i n s t a l l   r e t u r n   v a l u e s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   S e t u p R e t V a l ( R e t V a l )  
         S e l e c t   C a s e   R e t V a l  
                 C a s e   0   :   S e t u p R e t V a l   =   " S u c c e s s "  
                 ' m s i e x e c   r e t u r n   v a l u e s  
                 C a s e   1 2 5 9   :   S e t u p R e t V a l   =   " A P P H E L P _ B L O C K "  
                 C a s e   1 6 0 1   :   S e t u p R e t V a l   =   " I N S T A L L _ S E R V I C E _ F A I L U R E "  
                 C a s e   1 6 0 2   :   S e t u p R e t V a l   =   " I N S T A L L _ U S E R E X I T "  
                 C a s e   1 6 0 3   :   S e t u p R e t V a l   =   " I N S T A L L _ F A I L U R E "  
                 C a s e   1 6 0 4   :   S e t u p R e t V a l   =   " I N S T A L L _ S U S P E N D "  
                 C a s e   1 6 0 5   :   S e t u p R e t V a l   =   " U N K N O W N _ P R O D U C T "  
                 C a s e   1 6 0 6   :   S e t u p R e t V a l   =   " U N K N O W N _ F E A T U R E "  
                 C a s e   1 6 0 7   :   S e t u p R e t V a l   =   " U N K N O W N _ C O M P O N E N T "  
                 C a s e   1 6 0 8   :   S e t u p R e t V a l   =   " U N K N O W N _ P R O P E R T Y "  
                 C a s e   1 6 0 9   :   S e t u p R e t V a l   =   " I N V A L I D _ H A N D L E _ S T A T E "  
                 C a s e   1 6 1 0   :   S e t u p R e t V a l   =   " B A D _ C O N F I G U R A T I O N "  
                 C a s e   1 6 1 1   :   S e t u p R e t V a l   =   " I N D E X _ A B S E N T "  
                 C a s e   1 6 1 2   :   S e t u p R e t V a l   =   " I N S T A L L _ S O U R C E _ A B S E N T "  
                 C a s e   1 6 1 3   :   S e t u p R e t V a l   =   " I N S T A L L _ P A C K A G E _ V E R S I O N "  
                 C a s e   1 6 1 4   :   S e t u p R e t V a l   =   " P R O D U C T _ U N I N S T A L L E D "  
                 C a s e   1 6 1 5   :   S e t u p R e t V a l   =   " B A D _ Q U E R Y _ S Y N T A X "  
                 C a s e   1 6 1 6   :   S e t u p R e t V a l   =   " I N V A L I D _ F I E L D "  
                 C a s e   1 6 1 8   :   S e t u p R e t V a l   =   " I N S T A L L _ A L R E A D Y _ R U N N I N G "  
                 C a s e   1 6 1 9   :   S e t u p R e t V a l   =   " I N S T A L L _ P A C K A G E _ O P E N _ F A I L E D "  
                 C a s e   1 6 2 0   :   S e t u p R e t V a l   =   " I N S T A L L _ P A C K A G E _ I N V A L I D "  
                 C a s e   1 6 2 1   :   S e t u p R e t V a l   =   " I N S T A L L _ U I _ F A I L U R E "  
                 C a s e   1 6 2 2   :   S e t u p R e t V a l   =   " I N S T A L L _ L O G _ F A I L U R E "  
                 C a s e   1 6 2 3   :   S e t u p R e t V a l   =   " I N S T A L L _ L A N G U A G E _ U N S U P P O R T E D "  
                 C a s e   1 6 2 4   :   S e t u p R e t V a l   =   " I N S T A L L _ T R A N S F O R M _ F A I L U R E "  
                 C a s e   1 6 2 5   :   S e t u p R e t V a l   =   " I N S T A L L _ P A C K A G E _ R E J E C T E D "  
                 C a s e   1 6 2 6   :   S e t u p R e t V a l   =   " F U N C T I O N _ N O T _ C A L L E D "  
                 C a s e   1 6 2 7   :   S e t u p R e t V a l   =   " F U N C T I O N _ F A I L E D "  
                 C a s e   1 6 2 8   :   S e t u p R e t V a l   =   " I N V A L I D _ T A B L E "  
                 C a s e   1 6 2 9   :   S e t u p R e t V a l   =   " D A T A T Y P E _ M I S M A T C H "  
                 C a s e   1 6 3 0   :   S e t u p R e t V a l   =   " U N S U P P O R T E D _ T Y P E "  
                 C a s e   1 6 3 1   :   S e t u p R e t V a l   =   " C R E A T E _ F A I L E D "  
                 C a s e   1 6 3 2   :   S e t u p R e t V a l   =   " I N S T A L L _ T E M P _ U N W R I T A B L E "  
                 C a s e   1 6 3 3   :   S e t u p R e t V a l   =   " I N S T A L L _ P L A T F O R M _ U N S U P P O R T E D "  
                 C a s e   1 6 3 4   :   S e t u p R e t V a l   =   " I N S T A L L _ N O T U S E D "  
                 C a s e   1 6 3 5   :   S e t u p R e t V a l   =   " P A T C H _ P A C K A G E _ O P E N _ F A I L E D "  
                 C a s e   1 6 3 6   :   S e t u p R e t V a l   =   " P A T C H _ P A C K A G E _ I N V A L I D "  
                 C a s e   1 6 3 7   :   S e t u p R e t V a l   =   " P A T C H _ P A C K A G E _ U N S U P P O R T E D "  
                 C a s e   1 6 3 8   :   S e t u p R e t V a l   =   " P R O D U C T _ V E R S I O N "  
                 C a s e   1 6 3 9   :   S e t u p R e t V a l   =   " I N V A L I D _ C O M M A N D _ L I N E "  
                 C a s e   1 6 4 0   :   S e t u p R e t V a l   =   " I N S T A L L _ R E M O T E _ D I S A L L O W E D "  
                 C a s e   1 6 4 1   :   S e t u p R e t V a l   =   " S U C C E S S _ R E B O O T _ I N I T I A T E D "  
                 C a s e   1 6 4 2   :   S e t u p R e t V a l   =   " P A T C H _ T A R G E T _ N O T _ F O U N D "  
                 C a s e   1 6 4 3   :   S e t u p R e t V a l   =   " P A T C H _ P A C K A G E _ R E J E C T E D "  
                 C a s e   1 6 4 4   :   S e t u p R e t V a l   =   " I N S T A L L _ T R A N S F O R M _ R E J E C T E D "  
                 C a s e   1 6 4 5   :   S e t u p R e t V a l   =   " I N S T A L L _ R E M O T E _ P R O H I B I T E D "  
                 C a s e   1 6 4 6   :   S e t u p R e t V a l   =   " P A T C H _ R E M O V A L _ U N S U P P O R T E D "  
                 C a s e   1 6 4 7   :   S e t u p R e t V a l   =   " U N K N O W N _ P A T C H "  
                 C a s e   1 6 4 8   :   S e t u p R e t V a l   =   " P A T C H _ N O _ S E Q U E N C E "  
                 C a s e   1 6 4 9   :   S e t u p R e t V a l   =   " P A T C H _ R E M O V A L _ D I S A L L O W E D "  
                 C a s e   1 6 5 0   :   S e t u p R e t V a l   =   " I N V A L I D _ P A T C H _ X M L "  
                 C a s e   3 0 1 0   :   S e t u p R e t V a l   =   " S U C C E S S _ R E B O O T _ R E Q U I R E D "  
                 C a s e   E l s e   :   S e t u p R e t V a l   =   " U n k n o w n   R e t u r n   V a l u e "  
         E n d   S e l e c t  
 E n d   F u n c t i o n   ' S e t u p R e t V a l  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l e t e F i l e  
 '  
 '       W r a p p e r   t o   d e l e t e   a   f i l e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   D e l e t e F i l e ( s F i l e )  
         D i m   F i l e ,   a t t r  
         D i m   s D e l F i l e ,   s F i l e N a m e ,   s N e w P a t h  
         D i m   f K e e p  
          
         O n   E r r o r   R e s u m e   N e x t  
  
         f K e e p   =   d i c K e e p F o l d e r . E x i s t s ( L C a s e ( s F i l e ) )  
         I f   ( N O T   f K e e p   A N D   f 6 4 )   T h e n   f K e e p   =   d i c K e e p F o l d e r . E x i s t s ( L C a s e ( W o w 6 4 F o l d e r ( s F i l e ) ) )  
         I f   f K e e p   T h e n  
                 L o g O n l y   " D i s a l l o w i n g   t h e   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   s F i l e  
                 I f   N O T   f F o r c e   T h e n   E x i t   S u b  
         E n d   I f  
  
         '   c h e c k   o n   f o r c e d   d e l e t e  
         I f   f K e e p   T h e n  
                 L o g O n l y   " E n f o r c e d   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   s F i l e  
                 L o g O n l y   "       R e m a i n i n g   a p p l i c a t i o n s   w i l l   n e e d   a   r e p a i r ! "  
         E n d   I f  
  
         I f   o F s o . F i l e E x i s t s ( s F i l e )   T h e n  
                 s D e l F i l e   =   s F i l e  
         E l s e I f   f 6 4   A N D   o F s o . F i l e E x i s t s ( W o w 6 4 F o l d e r ( s F i l e ) )   T h e n  
                 s D e l F i l e   =   W o w 6 4 F o l d e r ( s F i l e )  
         E l s e  
                 L o g O n l y   " P a t h   n o t   f o u n d .   C a n n o t   n o t   d e l e t e   f o l d e r :   "   &   s F i l e  
                 E x i t   S u b  
         E n d   I f  
         I f   N o t   f D e t e c t O n l y   T h e n    
                 L o g O n l y   " D e l e t e   f i l e :   "   &   s D e l F i l e  
 	 	 S e t   F i l e   =   o F s o . G e t F i l e ( s D e l F i l e )  
                 '   e n s u r e   r e a d - o n l y   f l a g   i s   n o t   s e t  
                 a t t r   =     F i l e . A t t r i b u t e s  
                 I f   C B o o l ( a t t r   A N D   1 )   T h e n   F i l e . A t t r i b u t e s   =   a t t r   A N D   ( a t t r   -   1 )  
                 '   a d d   f o l d e r   t o   e m p t y   f o l d e r   c l e a n u p   l i s t  
                 I f   N O T   d i c D e l F o l d e r . E x i s t s ( F i l e . P a r e n t F o l d e r . P a t h )   T h e n   d i c D e l F o l d e r . A d d   F i l e . P a r e n t F o l d e r . P a t h ,   F i l e . P a r e n t F o l d e r . P a t h  
                 '   d e l e t e   t h e   f i l e  
                 s F i l e   =   F i l e . P a t h  
                 F i l e . D e l e t e   T r u e  
                 S e t   F i l e   =   N o t h i n g  
                 I f   E r r   < >   0   T h e n  
                         C h e c k E r r o r   " D e l e t e F i l e "  
                         '   s c h e d u l e   f i l e   f o r   d e l e t e   o n   n e x t   r e b o o t  
                         S c h e d u l e D e l e t e F i l e   s F i l e  
                 E n d   I f   ' E r r   < >   0  
         E l s e  
                 L o g O n l y   " P r e v i e w   m o d e .   D i s a l l o w i n g   d e l e t e   f o r   f o l d e r :   "   &   s D e l F i l e  
         E n d   I f  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' D e l e t e F i l e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l e t e F o l d e r  
 '  
 '       W r a p p e r   t o   d e l e t e   a   f o l d e r  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   D e l e t e F o l d e r ( s F o l d e r )  
         D i m   F o l d e r ,   f l d ,   a t t r  
         D i m   s D e l F o l d e r ,   s F o l d e r N a m e ,   s N e w P a t h ,   s C m d  
         D i m   f K e e p  
          
         '   e n s u r e   t r a i l i n g   " \ "  
         '   t r a i l i n g   \   i s   r e q u i r e d   f o r   d i c K e e p F o l d e r   c o m p a r i s o n s  
         s F o l d e r   =   s F o l d e r   &   " \ "  
         W h i l e   I n S t r ( s F o l d e r , " \ \ " ) > 0  
                 s F o l d e r   =   R e p l a c e ( s F o l d e r , " \ \ " , " \ " )  
         W e n d  
  
         '   p r e v e n t   d e l e t e   o f   f o l d e r s   t h a t   a r e   k n o w n   t o   b e   s t i l l   r e q u i r e d  
         f K e e p   =   d i c K e e p F o l d e r . E x i s t s ( L C a s e ( s F o l d e r ) )  
         I f   ( N O T   f K e e p   A N D   f 6 4 )   T h e n   f K e e p   =   d i c K e e p F o l d e r . E x i s t s ( L C a s e ( W o w 6 4 F o l d e r ( s F o l d e r ) ) )  
         I f   f K e e p   T h e n  
                 L o g O n l y   " D i s a l l o w i n g   t h e   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   s F o l d e r  
                 I f   N O T   f F o r c e   T h e n   E x i t   S u b  
         E n d   I f  
  
         '   c h e c k   o n   f o r c e d   d e l e t e  
         I f   f K e e p   T h e n  
                 L o g O n l y   " E n f o r c e d   d e l e t e   o f   s t i l l   r e q u i r e d   k e y p a t h   e l e m e n t :   "   &   s F o l d e r  
                 L o g O n l y   "       R e m a i n i n g   a p p l i c a t i o n s   w i l l   n e e d   a   r e p a i r ! "  
         E n d   I f  
          
         '   s t r i p   t r a i l i n g   " \ "  
         I f   L e n ( s F o l d e r )   >   1   T h e n  
                 s F o l d e r   =   L e f t ( s F o l d e r ,   L e n ( s F o l d e r )   -   1 )  
         E n d   I f  
  
         O n   E r r o r   R e s u m e   N e x t  
         I f   o F s o . F o l d e r E x i s t s ( s F o l d e r )   T h e n    
                 s D e l F o l d e r   =   s F o l d e r  
         E l s e I f   f 6 4   A N D   o F s o . F o l d e r E x i s t s ( W o w 6 4 F o l d e r ( s F o l d e r ) )   T h e n    
                 s D e l F o l d e r   =   W o w 6 4 F o l d e r ( s F o l d e r )  
         E l s e  
                 L o g O n l y   " P a t h   n o t   f o u n d .   C a n n o t   n o t   d e l e t e   f o l d e r :   "   &   s F o l d e r  
                 E x i t   S u b  
         E n d   I f  
         I f   N o t   f D e t e c t O n l y   T h e n    
                 L o g O n l y   " D e l e t e   f o l d e r :   "   &   s D e l F o l d e r  
                 S e t   F o l d e r   =   o F s o . G e t F o l d e r ( s D e l F o l d e r )  
                 '   e n s u r e   t o   r e m o v e   r e a d   o n l y   f l a g  
                 a t t r   =     F o l d e r . A t t r i b u t e s  
                 I f   C B o o l ( a t t r   A N D   1 )   T h e n   F o l d e r . A t t r i b u t e s   =   a t t r   A N D   ( a t t r   -   1 )  
                 '   a d d   t o   e m p t y   f o l d e r   c l e a n u p   l i s t  
                 I f   N O T   d i c D e l F o l d e r . E x i s t s ( F o l d e r . P a t h )   T h e n   d i c D e l F o l d e r . A d d   F o l d e r . P a t h ,   F o l d e r . P a t h  
                 '   d e l e t e   t h e   f o l d e r  
                 '   f o r   p e r f o r m a n c e   r e a s o n s   t r y   ' r d '   f i r s t  
                 S e t   F o l d e r   =   N o t h i n g  
                 s C m d   =   " c m d . e x e   / c   r d   / s   "   &   c h r ( 3 4 )   &   s D e l F o l d e r   &   c h r ( 3 4 )   &   "   / q "  
                 o W S h e l l . R u n   s C m d ,   0 ,   T r u e  
                 I f   N O T   o F s o . F o l d e r E x i s t s ( s D e l F o l d e r )   T h e n   E x i t   S u b  
                  
                 '   r d   d i d n ' t   w o r k   c h e c k   w i t h   F i l e S y s t e m O b j e c t  
                 S e t   F o l d e r   =   o F s o . G e t F o l d e r ( s D e l F o l d e r )  
                 F o l d e r . D e l e t e   T r u e  
                 S e t   F o l d e r   =   N o t h i n g  
                  
                 '   e r r o r   h a n d l i n g  
                 I f   E r r   < >   0   T h e n  
                         S e l e c t   C a s e   E r r  
                         C a s e   7 0  
                                 '   A c c e s s   D e n i e d  
                                 '   R e t r y   a f t e r   c l o s i n g   r u n n i n g   p r o c e s s e s  
                                 C h e c k E r r o r   " D e l e t e F o l d e r "  
                                 I f   N O T   f R e r u n   T h e n  
                                         C l o s e O f f i c e A p p s  
                                         '   a t t e m p t   ' r d '   c o m m a n d  
                                         L o g O n l y   "       A t t e m p t   t o   r e m o v e   w i t h   ' r d '   c o m m a n d "  
                                         s C m d   =   " c m d . e x e   / c   r d   / s   "   &   c h r ( 3 4 )   &   s D e l F o l d e r   &   c h r ( 3 4 )   &   "   / q "  
                                         o W S h e l l . R u n   s C m d ,   0 ,   T r u e  
                                         I f   N O T   o F s o . F o l d e r E x i s t s ( s D e l F o l d e r )   T h e n   E x i t   S u b  
                                 E n d   I f  
  
                         C a s e   7 6    
                                 '   c h e c k   o n   i n v a l i d   p a t h   l e n g t   i s s u e s   E r r   7 6   ( 0 x 4 C )   " P a t h   n o t   f o u n d "  
                                 '   a t t e m p t   ' r d '   c o m m a n d  
                                 C h e c k E r r o r   " D e l e t e F o l d e r "  
                                 L o g O n l y   "       A t t e m p t   t o   r e m o v e   w i t h   ' r d '   c o m m a n d "  
                                 s C m d   =   " c m d . e x e   / c   r d   / s   "   &   c h r ( 3 4 )   &   s D e l F o l d e r   &   c h r ( 3 4 )   &   "   / q "  
                                 o W S h e l l . R u n   s C m d ,   0 ,   T r u e  
                                 I f   N O T   o F s o . F o l d e r E x i s t s ( s D e l F o l d e r )   T h e n   E x i t   S u b  
                         E n d   S e l e c t  
                          
                         '   s t i l   f a i l e d !  
                         L o g   "       F a i l e d   t o   d e l e t e   f o l d e r :   "   &   s D e l F o l d e r  
                         C h e c k E r r o r   " D e l e t e F o l d e r "  
  
                         '   t r y   t o   d e l e t e   a s   m a n y   f o l d e r   c o n t e n t s   a s   p o s s i b l e  
                         '   b e f o r e   t h e   r e c u r s i v e   e r r o r   h a n d l i n g   i s   c a l l e d  
                         S e t   F o l d e r   =   o F s o . G e t F o l d e r ( s D e l F o l d e r )  
                         F o r   E a c h   f l d   i n   F o l d e r . S u b f o l d e r s  
                                 s C m d   =   " c m d . e x e   / c   r d   / s   "   &   c h r ( 3 4 )   &   f l d . P a t h   &   c h r ( 3 4 )   &   "   / q "  
                                 o W S h e l l . R u n   s C m d ,   0 ,   T r u e  
                         N e x t   ' f l d  
                         s C m d   =   " c m d . e x e   / c   d e l   "   &   c h r ( 3 4 )   &   f l d . P a t h   &   " \ * . * "   &   c h r ( 3 4 )  
                         o W S h e l l . R u n   s C m d ,   0 ,   T r u e  
                         S e t   F o l d e r   =   N o t h i n g  
  
                         '   s c h e d u l e   a n   a d d i t i o n a l   r u n   o f   t h e   t o o l   a f t e r   r e b o o t  
                         I f   N O T   f R e r u n   T h e n   R e r u n  
  
                         '   s c h e d u l e   f o l d e r   f o r   d e l e t e   o n   n e x t   r e b o o t  
                         S c h e d u l e D e l e t e F o l d e r   s D e l F o l d e r  
                 E n d   I f   ' E r r   < >   0  
         E l s e  
                 L o g O n l y   " P r e v i e w   m o d e .   D i s a l l o w i n g   d e l e t e   o f   f o l d e r :   "   &   s D e l F o l d e r  
         E n d   I f  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' D e l e t e F o l d e r  
  
 S u b   D e l e t e F o l d e r _ W M I   ( s F o l d e r )  
         D i m   F o l d e r ,   F o l d e r s  
         D i m   s W q l F o l d e r  
         D i m   i R e t  
  
         s W q l F o l d e r   =   R e p l a c e ( s F o l d e r ,   " \ " ,   " \ \ " )  
         S e t   F o l d e r s   =   o W m i L o c a l . E x e c Q u e r y   ( " S e l e c t   *   f r o m   W i n 3 2 _ D i r e c t o r y   w h e r e   n a m e   =   ' "   &   s W q l F o l d e r   &   " ' " )  
         F o r   E a c h   F o l d e r   i n   F o l d e r s  
                 i R e t   =   F o l d e r . D e l e t e  
         N e x t   ' F o l d e r  
         L o g O n l y   "       D e l e t e   ( w m i )   f o r   f o l d e r   "   &   s F o l d e r   &   "   r e t u r n e d :   "   &   i R e t  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       W o w 6 4 F o l d e r  
 '  
 '       R e t u r n s   t h e   W O W   f o l d e r   s t r u c t u r e   t o   h a n d l e   f o l d e r - p a t h   o p e r a t i o n s   o n  
 '       6 4   b i t   e n v i r o n m e n t s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   W o w 6 4 F o l d e r ( s F o l d e r )  
         I f   L C a s e ( L e f t ( s F o l d e r ,   L e n ( s W i n D i r   &   " \ S y s t e m 3 2 " ) ) )   =   L C a s e ( s W i n D i r   &   " \ S y s t e m 3 2 " )   T h e n    
                 W o w 6 4 F o l d e r   =   s W i n D i r   &   " \ s y s w o w 6 4 "   &   R i g h t ( s F o l d e r ,   L e n ( s F o l d e r )   -   L e n ( s W i n D i r   &   " \ S y s t e m 3 2 " ) )  
         E l s e I f   L C a s e ( L e f t ( s F o l d e r ,   L e n ( s P r o g r a m F i l e s ) ) )   =   L C a s e ( s P r o g r a m F i l e s )   T h e n    
                 W o w 6 4 F o l d e r   =   s P r o g r a m F i l e s X 8 6   &   R i g h t ( s F o l d e r ,   L e n ( s F o l d e r )   -   L e n ( s P r o g r a m F i l e s ) )  
         E l s e  
                 W o w 6 4 F o l d e r   =   " ? "   ' R e t u r n   i n v a l i d   s t r i n g   t o   e n s u r e   t h e   f o l d e r   c a n n o t   e x i s t  
         E n d   I f  
 E n d   F u n c t i o n   ' W o w 6 4 F o l d e r  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S c h e d u l e D e l e t e F i l e  
 '  
 '       A d d s   a   f i l e   t o   t h e   l i s t   o f   i t e m s   t o   d e l e t e   o n   r e b o o t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S c h e d u l e D e l e t e F i l e   ( s F i l e )  
         I f   N O T   d i c D e l I n U s e . E x i s t s ( s F i l e )   T h e n   d i c D e l I n U s e . A d d   s F i l e ,   s F i l e   E l s e   E x i t   S u b  
         L o g O n l y   " A d d i n g   f i l e   i n   u s e   f o r   d e l e t e   o n   r e b o o t :   "   &   s F i l e  
         f R e b o o t R e q u i r e d   =   T r u e  
         S e t E r r o r   E R R O R _ R E B O O T _ R E Q U I R E D  
 E n d   S u b   ' S c h e d u l e D e l e t e F i l e  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S c h e d u l e D e l e t e F o l d e r  
 '  
 '       R e c u r s i v e l y   a d d s   a   f o l d e r   a n d   i t s   c o n t e n t s   t o   t h e   l i s t   o f    
 '       i t e m s   t o   d e l e t e   o n   r e b o o t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S c h e d u l e D e l e t e F o l d e r   ( s F o l d e r )  
         D i m   o F o l d e r ,   f l d ,   f i l e ,   a t t r  
  
 	 S e t   o F o l d e r   =   o F s o . G e t F o l d e r ( s F o l d e r )  
 	 '   e x c l u d e   h i d d e n   s y s t e m     f o l d e r s  
         a t t r   =   o F o l d e r . A t t r i b u t e s  
         I f   C B o o l ( a t t r   A N D   6 )   T h e n   E x i t   S u b  
  
 	 F o r   E a c h   f l d   I n   o F o l d e r . S u b F o l d e r s  
 	 	 D e l e t e F o l d e r   f l d . P a t h  
 	 N e x t  
 	 F o r   E a c h   f i l e   I n   o F o l d e r . F i l e s  
 	 	 D e l e t e F i l e   f i l e . P a t h  
 	 N e x t  
 	 I f   N O T   d i c D e l I n U s e . E x i s t s ( o F o l d e r . P a t h )   T h e n   d i c D e l I n U s e . A d d   o F o l d e r . P a t h ,   " "   E l s e   E x i t   S u b  
         L o g O n l y   " A d d i n g   f o l d e r   f o r   d e l e t e   o n   r e b o o t :   "   &   o F o l d e r . P a t h  
         f R e b o o t R e q u i r e d   =   T r u e  
         S e t E r r o r   E R R O R _ R E B O O T _ R E Q U I R E D  
 E n d   S u b   ' S c h e d u l e D e l e t e F i l e  
  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S c h e d u l e D e l e t e E x  
 '  
 '       S c h e d u l e s   t h e   d e l e t e   o f   f i l e s / f o l d e r s   i n   u s e   o n   n e x t   r e b o o t   b y   a d d i n g  
 '       a f f e c t e d   f i l e s / f o l d e r s   t o   t h e   P e n d i n g F i l e R e n a m e O p e r a t i o n s   r e g i s t r y   e n t r y  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S c h e d u l e D e l e t e E x   ( )  
         D i m   k e y ,   h D e f K e y ,   s K e y N a m e ,   s V a l u e N a m e  
         D i m   i  
         D i m   a r r D a t a  
  
         h D e f K e y   =   H K L M  
         s K e y N a m e   =   " S Y S T E M \ C u r r e n t C o n t r o l S e t \ C o n t r o l \ S e s s i o n   M a n a g e r "  
         s V a l u e N a m e   =   " P e n d i n g F i l e R e n a m e O p e r a t i o n s "  
          
         L o g H 2   " A d d i n g   "   &   d i c D e l I n U s e . C o u n t   &   "   P e n d i n g F i l e R e n a m e O p e r a t i o n s "  
         I f   N O T   R e g V a l E x i s t s ( h D e f K e y ,   s K e y N a m e ,   s V a l u e N a m e )   T h e n  
                 R e D i m   a r r D a t a ( - 1 )  
         E l s e  
                 o R e g . G e t M u l t i S t r i n g V a l u e   h D e f K e y ,   s K e y N a m e ,   s V a l u e N a m e ,   a r r D a t a  
         E n d   I f  
         i   =   U B o u n d ( a r r D a t a )   +   1  
         R e D i m   P r e s e r v e   a r r D a t a ( U B o u n d ( a r r D a t a )   +   ( d i c D e l I n U s e . C o u n t   *   2 ) )  
         F o r   E a c h   k e y   i n   d i c D e l I n U s e . K e y s  
                 L o g O n l y   "       "   &   k e y  
                 a r r D a t a ( i )   =   " \ ? ? \ "   &   k e y  
                 a r r D a t a ( i   +   1 )   =   " "  
                 i   =   i   +   2  
         N e x t   ' k e y  
         o R e g . S e t M u l t i S t r i n g V a l u e   h D e f K e y ,   s K e y N a m e ,   s V a l u e N a m e ,   a r r D a t a  
 E n d   S u b   ' S c h e d u l e D e l e t e E x  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l e t e E m p t y F o l d e r s  
 '  
 '       D e l e t e s   a n   i n d i v i d u a l   f o l d e r   s t r u c t u r e   i f   e m p t y  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   D e l e t e E m p t y F o l d e r   ( s F o l d e r )  
         D i m   F o l d e r  
          
         '   c o s m e t i c '   t a s k   d o n ' t   f a i l   o n   e r r o r  
         O n   E r r o r   R e s u m e   N e x t  
         I f   o F s o . F o l d e r E x i s t s ( s F o l d e r )   T h e n  
                 S e t   F o l d e r   =   o F s o . G e t F o l d e r ( s F o l d e r )  
                 I f   ( F o l d e r . S u b f o l d e r s . C o u n t   =   0 )   A N D   ( F o l d e r . F i l e s . C o u n t   =   0 )   T h e n    
                         S e t   F o l d e r   =   N o t h i n g  
                         S m a r t D e l e t e F o l d e r   s F o l d e r  
                 E n d   I f  
         E n d   I f  
         C h e c k E r r o r   " D e l e t e E m p t y F o l d e r "  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' D e l e t e E m p t y F o l d e r s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       D e l e t e E m p t y F o l d e r s  
 '  
 '       D e l e t e   a n   e m p t y   f o l d e r   s t r u c t u r e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   D e l e t e E m p t y F o l d e r s  
         D i m   F o l d e r  
         D i m   s F o l d e r  
          
         '   c o s m e t i c '   t a s k   d o n ' t   f a i l   o n   e r r o r  
         O n   E r r o r   R e s u m e   N e x t  
         D e l e t e E m p t y F o l d e r   s C o m m o n P r o g r a m F i l e s   &   " \ M i c r o s o f t   S h a r e d \ O f f i c e 1 5 "  
         D e l e t e E m p t y F o l d e r   s C o m m o n P r o g r a m F i l e s   &   " \ M i c r o s o f t   S h a r e d \ O f f i c e 1 6 "  
         D e l e t e E m p t y F o l d e r   s C o m m o n P r o g r a m F i l e s   &   " \ M i c r o s o f t   S h a r e d \ "    
         D e l e t e E m p t y F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 5 "  
         D e l e t e E m p t y F o l d e r   s P r o g r a m F i l e s   &   " \ M i c r o s o f t   O f f i c e \ O f f i c e 1 6 "  
          
         F o r   E a c h   s F o l d e r   i n   d i c D e l F o l d e r . K e y s  
                 I f   o F s o . F o l d e r E x i s t s ( s F o l d e r )   T h e n  
                         S e t   F o l d e r   =   o F s o . G e t F o l d e r ( s F o l d e r )  
                         I f   ( F o l d e r . S u b f o l d e r s . C o u n t   =   0 )   A N D   ( F o l d e r . F i l e s . C o u n t   =   0 )   T h e n    
                                 S e t   F o l d e r   =   N o t h i n g  
                                 S m a r t D e l e t e F o l d e r   s F o l d e r  
                         E n d   I f  
                 E n d   I f  
         N e x t   ' s F o l d e r  
         C h e c k E r r o r   " D e l e t e E m p t y F o l d e r s "  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' D e l e t e E m p t y F o l d e r s  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S m a r t D e l e t e F o l d e r  
 '  
 '       W r a p p e r   t o   d e l e t e   a   f o l d e r   a n d   t h e   e m p t y   p a r e n t   f o l d e r   s t r u c t u r e  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S m a r t D e l e t e F o l d e r ( s F o l d e r )  
         D i m   s D e l F o l d e r  
  
         I f   o F s o . F o l d e r E x i s t s ( s F o l d e r )   T h e n  
                 s D e l F o l d e r   =   s F o l d e r  
         E l s e I f   f 6 4   A N D   o F s o . F o l d e r E x i s t s ( W o w 6 4 F o l d e r ( s F o l d e r ) )   T h e n  
                 s D e l F o l d e r   =   W o w 6 4 F o l d e r ( s F o l d e r )  
         E l s e  
                 E x i t   S u b  
         E n d   I f  
  
         I f   N o t   f D e t e c t O n l y   T h e n  
                 L o g O n l y   " R e q u e s t   S m a r t D e l e t e   f o r   f o l d e r :   "   &   s D e l F o l d e r  
                 S m a r t D e l e t e F o l d e r E x   s D e l F o l d e r  
         E l s e  
                 L o g O n l y   " P r e v i e w   m o d e .   D i s a l l o w i n g   S m a r t D e l e t e   r e q u e s t   f o r   f o l d e r :   "   &   s D e l F o l d e r  
         E n d   I f  
 E n d   S u b   ' S m a r t D e l e t e F o l d e r  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S m a r t D e l e t e F o l d e r E x  
 '  
 '       E x e c u t e s   t h e   f o l d e r   d e l e t e   o p e r a t i o n ( s )  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S m a r t D e l e t e F o l d e r E x ( s F o l d e r )  
         D i m   F o l d e r  
          
         O n   E r r o r   R e s u m e   N e x t  
         D e l e t e F o l d e r   s F o l d e r   :   C h e c k E r r o r   " S m a r t D e l e t e F o l d e r E x "  
         O n   E r r o r   G o t o   0  
         S e t   F o l d e r   =   o F s o . G e t F o l d e r ( o F s o . G e t P a r e n t F o l d e r N a m e ( s F o l d e r ) )  
         I f   ( F o l d e r . S u b f o l d e r s . C o u n t   =   0 )   A N D   ( F o l d e r . F i l e s . C o u n t   =   0 )   T h e n   S m a r t D e l e t e F o l d e r E x ( F o l d e r . P a t h )  
 E n d   S u b   ' S m a r t D e l e t e F o l d e r E x  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e s t o r e E x p l o r e r  
 '  
 '       E n s u r e   W i n d o w s   E x p l o r e r   i s   r e s t a r t e d   i f   n e e d e d  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e s t o r e E x p l o r e r  
         D i m   P r o c e s s e s ,   R e s u l t ,   o A T ,   D a t e T i m e ,   J o b I D  
         D i m   s C m d  
          
         ' N o n   c r i t i c a l   r o u t i n e .   D o n ' t   f a i l   o n   e r r o r  
         O n   E r r o r   R e s u m e   N e x t  
         w s c r i p t . s l e e p   1 0 0 0  
         S e t   P r o c e s s e s   =   o W m i L o c a l . E x e c Q u e r y ( " S e l e c t   *   F r o m   W i n 3 2 _ P r o c e s s   W h e r e   N a m e = ' e x p l o r e r . e x e ' " )  
         I f   P r o c e s s e s . C o u n t   <   1   T h e n    
                 o W S h e l l . R u n   " e x p l o r e r . e x e "  
                 ' T o   h a n d l e   t h i s   i n   c a s e   o f   S y s t e m   c o n t e x t ,   s c h e d u l e   a n d   r u n   a s   i n t e r a c t i v e   t a s k  
                 o W S h e l l . R u n   " S C H T A S K S   / C r e a t e   / T N   O f f S c r E x   / T R   e x p l o r e r   / S C   O N C E   / S T   1 2 : 0 0   / I T " ,   0 ,   T r u e  
                 o W S h e l l . R u n   " S C H T A S K S   / R u n   / T N   O f f S c r E x " ,   0 ,   T r u e  
                 o W S h e l l . R u n   " S C H T A S K S   / D e l e t e   / T N   O f f S c r E x   / F " ,   0 ,   F a l s e  
         E n d   I f  
         O n   E r r o r   G o t o   0  
 E n d   S u b   ' R e s t o r e E x p l o e r  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       M y J o i n  
 '  
 '       R e p l a c e m e n t   f u n c t i o n   t o   t h e   i n t e r n a l   J o i n   f u n c t i o n   t o   p r e v e n t   f a i l u r e s  
 '       t h a t   w e r e   s e e n   i n   s o m e   i n s t a n c e s  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 F u n c t i o n   M y J o i n ( a r r T o J o i n ,   s S e p a r a t o r )  
         D i m   s J o i n e d  
         D i m   i  
  
         s J o i n e d   =   " "  
         I f   I s A r r a y ( a r r T o J o i n )   T h e n  
                 F o r   i   =   0   T o   U B o u n d ( a r r T o J o i n )  
                         s J o i n e d   =   s J o i n e d   &   a r r T o J o i n ( i )   &   s S e p a r a t o r  
                 N e x t   ' i  
         E n d   I f  
         I f   L e n ( s J o i n e d )   >   1   T h e n   s J o i n e d   =   L e f t ( s J o i n e d ,   L e n ( s J o i n e d )   -   1 )  
         M y J o i n   =   s J o i n e d  
 E n d   F u n c t i o n  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       R e r u n  
 '  
 '       F l a g   n e e d   f o r   r e b o o t   a n d   s c h e d u l e   a u t o r u n   t o   r u n   t h e   t o o l   a g a i n   o n   r e b o o t .  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   R e r u n   ( )  
         D i m   s V a l u e  
  
         '   c h e c k   i f   R e r u n   h a s   a l r e a d y   b e e n   c a l l e d  
         I f   f R e r u n   T h e n   E x i t   S u b  
  
         '   s e t   R e r u n   f l a g  
         f R e r u n   =   T r u e  
  
         '   c h e c k   i f   t h e   p r e v i o u s   r u n   a l r e a d y   i n i t i a t e d   t h e   R e r u n  
         I f   R e g R e a d V a l u e ( H K C U ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l e a n C 2 R " ,   " R e r u n " ,   s V a l u e ,   " R E G _ D W O R D " )   T h e n  
                 '   R e r u n   h a s   a l r e a d y   b e e n   t r i e d  
                 L o g H 2   " E r r o r :   R e m o v a l   f a i l e d "  
                 S e t E r r o r   E R R O R _ D C A F _ F A I L U R E  
                 E x i t   S u b  
         E n d   I f  
  
         f R e b o o t R e q u i r e d   =   T r u e  
         S e t E r r o r   E R R O R _ R E B O O T _ R E Q U I R E D  
         S e t E r r o r   E R R O R _ I N C O M P L E T E  
  
         '   c a c h e   t h e   s c r i p t   t o   t h e   l o c a l   s c r u b   f o l d e r  
         o F s o . C o p y F i l e   W S c r i p t . s c r i p t F u l l N a m e ,   s S c r u b D i r   &   " \ "   &   S C R I P T F I L E  
  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E "  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t "  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e "  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 "  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l e a n C 2 R "  
         o R e g . S e t D W o r d V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ O f f i c e \ 1 5 . 0 \ C l e a n C 2 R " ,   " R e r u n " ,   1  
  
         f S e t R u n O n c e   =   T r u e  
 '         o R e g . C r e a t e K e y   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n O n c e "  
 '         o R e g . S e t S t r i n g V a l u e   H K C U ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n O n c e " ,   " C l e a n C 2 R " ,   " c s c r i p t . e x e   "   &   c h r ( 3 4 )   &   s S c r u b D i r   &   " \ "   &   S C R I P T F I L E   &   c h r ( 3 4 )  
 E n d   S u b  
  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 '       S e t R u n O n c e  
 '  
 '       C r e a t e   a   R u n O n c e   e n t r y   t o   r e s u m e   s e t u p   a f t e r   a   r e b o o t  
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 S u b   S e t R u n O n c e  
         D i m   s V a l u e  
  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n "  
         o R e g . C r e a t e K e y   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n O n c e "  
         s V a l u e   =   " c s c r i p t . e x e   "   &   c h r ( 3 4 )   &     s S c r u b D i r   &   " \ "   &   S C R I P T F I L E   &   c h r ( 3 4 )   &   "   / N o E l e v a t e   / R e l a u n c h e d "  
         o R e g . S e t S t r i n g V a l u e   H K L M ,   " S O F T W A R E \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ R u n O n c e " ,   " O 1 5 C l e a n U p " ,   s V a l u e  
  
 E n d   S u b   ' S e t R u n O n c e  
 