< # 
 . S Y N O P S I S 
     I n s t a l a d o r   i n t e r a c t i v o   d e l   C y b e r N e t   W i n d o w s   A g e n t . 
     D e s c a r g a   e l   M S I ,   p i d e   l o s   d a t o s   y   e j e c u t a   l a   i n s t a l a c i ó n   s i l e n c i o s a . 
 . E X A M P L E 
     . \ i n s t a l l . p s 1 
     . \ i n s t a l l . p s 1   - A p i K e y   " c m - x x x "   - P l a t f o r m U r l   " h t t p s : / / . . . " 
 # > 
 
 p a r a m ( 
     [ s t r i n g ] $ A p i K e y   =   ' ' , 
     [ s t r i n g ] $ P l a t f o r m U r l   =   ' h t t p s : / / c y b e r n e t m o n i t o r . d u c k d n s . o r g ' , 
     [ s w i t c h ] $ U n i n s t a l l 
 ) 
 
 #    % %  C a r g a r   e n s a m b l a d o s   p a r a   U I    % %
 t r y   { 
     A d d - T y p e   - A s s e m b l y N a m e   S y s t e m . W i n d o w s . F o r m s   - E r r o r A c t i o n   S t o p 
     A d d - T y p e   - A s s e m b l y N a m e   M i c r o s o f t . V i s u a l B a s i c   - E r r o r A c t i o n   S i l e n t l y C o n t i n u e 
 }   c a t c h   { 
     W r i t e - H o s t   " E r r o r   c a r g a n d o   i n t e r f a z   g r á f i c a :   $ _ "   - F o r e g r o u n d C o l o r   R e d 
     W r i t e - H o s t   " E j e c u t a   c o n   p a r á m e t r o s :   . \ i n s t a l l . p s 1   - A p i K e y   c m - x x x   - P l a t f o r m U r l   h t t p s : / / . . . "   - F o r e g r o u n d C o l o r   Y e l l o w 
     e x i t   1 
 } 
 
 f u n c t i o n   S h o w - I n p u t B o x ( $ T i t l e ,   $ P r o m p t ,   $ D e f a u l t   =   ' ' )   { 
     t r y   { 
         r e t u r n   [ M i c r o s o f t . V i s u a l B a s i c . I n t e r a c t i o n ] : : I n p u t B o x ( $ P r o m p t ,   $ T i t l e ,   $ D e f a u l t ) 
     }   c a t c h   { 
         W r i t e - H o s t   " $ P r o m p t "   - F o r e g r o u n d C o l o r   C y a n 
         r e t u r n   R e a d - H o s t 
     } 
 } 
 
 f u n c t i o n   S h o w - M e s s a g e B o x ( $ T e x t ,   $ T i t l e ,   $ T y p e   =   ' I n f o r m a t i o n ' )   { 
     $ i c o n   =   s w i t c h   ( $ T y p e )   { 
         ' I n f o r m a t i o n '   {   [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x I c o n ] : : I n f o r m a t i o n   } 
         ' W a r n i n g '   {   [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x I c o n ] : : W a r n i n g   } 
         ' E r r o r '   {   [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x I c o n ] : : E r r o r   } 
         d e f a u l t   {   [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x I c o n ] : : I n f o r m a t i o n   } 
     } 
     [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x ] : : S h o w ( $ T e x t ,   $ T i t l e , 
         [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x B u t t o n s ] : : O K ,   $ i c o n ) 
 } 
 
 f u n c t i o n   S h o w - Q u e s t i o n B o x ( $ T e x t ,   $ T i t l e )   { 
     $ r   =   [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x ] : : S h o w ( $ T e x t ,   $ T i t l e , 
         [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x B u t t o n s ] : : Y e s N o , 
         [ S y s t e m . W i n d o w s . F o r m s . M e s s a g e B o x I c o n ] : : Q u e s t i o n ) 
     r e t u r n   ( $ r   - e q   ' Y e s ' ) 
 } 
 
 #    % %  D e s i n s t a l a r    % %
 i f   ( $ U n i n s t a l l )   { 
     i f   ( S h o w - Q u e s t i o n B o x   " ¿ D e s i n s t a l a r   C y b e r N e t   A g e n t ? "   " D e s i n s t a l a c i ó n " )   { 
         s c h t a s k s   / D e l e t e   / T N   " C y b e r N e t   A g e n t "   / F   2 > $ n u l l 
         S t a r t - P r o c e s s   - W a i t   - N o N e w W i n d o w   m s i e x e c   - A r g u m e n t L i s t   " / x   $ e n v : T E M P \ c y b e r n e t - a g e n t . m s i   / q n "   - P a s s T h r u 
         R e m o v e - I t e m   " $ e n v : T E M P \ c y b e r n e t - a g e n t . m s i "   - F o r c e   - E r r o r A c t i o n   S i l e n t l y C o n t i n u e 
         S h o w - M e s s a g e B o x   " A g e n t e   d e s i n s t a l a d o . "   " C y b e r N e t   A g e n t " 
     } 
     r e t u r n 
 } 
 
 #    % %  T í t u l o    % %
 W r i t e - H o s t   " = = =   C y b e r N e t   W i n d o w s   A g e n t   I n s t a l l e r   = = = "   - F o r e g r o u n d C o l o r   C y a n 
 W r i t e - H o s t   " " 
 
 #    % %  P e d i r   d a t o s   s i   n o   v i e n e n   c o m o   p a r á m e t r o    % %
 i f   ( - n o t   $ A p i K e y )   { 
     $ A p i K e y   =   S h o w - I n p u t B o x   " C y b e r N e t   A g e n t "   " A P I   K e y   ( c r e a r   e n   C r e d e n c i a l e s   ’!  t i p o   A P I ) : "   " " 
     i f   ( - n o t   $ A p i K e y )   {   W r i t e - H o s t   " I n s t a l a c i ó n   c a n c e l a d a . "   - F o r e g r o u n d C o l o r   Y e l l o w ;   e x i t   1   } 
 } 
 
 $ P l a t f o r m U r l   =   S h o w - I n p u t B o x   " C y b e r N e t   A g e n t "   " U R L   d e   l a   p l a t a f o r m a : "   $ P l a t f o r m U r l 
 i f   ( - n o t   $ P l a t f o r m U r l )   {   $ P l a t f o r m U r l   =   ' h t t p s : / / c y b e r n e t m o n i t o r . d u c k d n s . o r g '   } 
 
 $ m a s k   =   i f   ( $ A p i K e y . L e n g t h   - g t   8 )   {   $ A p i K e y . S u b s t r i n g ( 0 ,   8 )   +   ' . . . '   }   e l s e   {   $ A p i K e y   } 
 W r i t e - H o s t   " P l a t a f o r m a :   $ P l a t f o r m U r l "   - F o r e g r o u n d C o l o r   G r a y 
 W r i t e - H o s t   " A P I   K e y :   $ m a s k "   - F o r e g r o u n d C o l o r   G r a y 
 W r i t e - H o s t   " " 
 
 #    % %  C o n f i r m a r    % %
 i f   ( - n o t   ( S h o w - Q u e s t i o n B o x   " P l a t a f o r m a :   $ P l a t f o r m U r l ` n A P I   K e y :   $ m a s k ` n ` n ¿ I n s t a l a r   a g e n t e ? "   " C o n f i r m a r   i n s t a l a c i ó n " ) )   { 
     W r i t e - H o s t   " C a n c e l a d o . "   - F o r e g r o u n d C o l o r   Y e l l o w ;   e x i t   1 
 } 
 
 #    % %  D e s c a r g a r   M S I    % %
 $ m s i U r l   =   " $ P l a t f o r m U r l / c y b e r n e t - a g e n t . m s i " 
 $ m s i P a t h   =   " $ e n v : T E M P \ c y b e r n e t - a g e n t - $ ( [ I O . P a t h ] : : G e t R a n d o m F i l e N a m e ( ) ) . m s i " 
 
 t r y   { 
     W r i t e - H o s t   " D e s c a r g a n d o   M S I . . . "   - F o r e g r o u n d C o l o r   C y a n 
     I n v o k e - W e b R e q u e s t   - U r i   $ m s i U r l   - O u t F i l e   $ m s i P a t h   - U s e B a s i c P a r s i n g   - E r r o r A c t i o n   S t o p 
     W r i t e - H o s t   "     '  D e s c a r g a d o   ( $ ( ( G e t - I t e m   $ m s i P a t h ) . L e n g t h   /   1 K B   - a s   [ i n t ] )   K B ) "   - F o r e g r o u n d C o l o r   G r e e n 
 }   c a t c h   { 
     $ l o c a l M s i   =   J o i n - P a t h   $ P S S c r i p t R o o t   " c y b e r n e t - a g e n t . m s i " 
     i f   ( T e s t - P a t h   $ l o c a l M s i )   { 
         C o p y - I t e m   $ l o c a l M s i   $ m s i P a t h 
         W r i t e - H o s t   "     '  U s a n d o   M S I   l o c a l "   - F o r e g r o u n d C o l o r   G r e e n 
     }   e l s e   { 
         W r i t e - H o s t   "     '  N o   s e   p u d o   d e s c a r g a r   e l   M S I   d e s d e   $ m s i U r l "   - F o r e g r o u n d C o l o r   R e d 
         W r i t e - H o s t   "         V e r i f i c a   l a   U R L   o   d e s c a r g a   m a n u a l m e n t e   e l   M S I . "   - F o r e g r o u n d C o l o r   Y e l l o w 
         S t a r t - S l e e p   3 ;   e x i t   1 
     } 
 } 
 
 #    % %  E j e c u t a r   M S I    % %
 W r i t e - H o s t   " I n s t a l a n d o . . . "   - F o r e g r o u n d C o l o r   C y a n 
 $ a r g   =   " / i   ` " $ m s i P a t h ` "   / q n   A P I K E Y = ` " $ A p i K e y ` "   P L A T F O R M U R L = ` " $ P l a t f o r m U r l ` " " 
 W r i t e - H o s t   "     m s i e x e c   $ a r g "   - F o r e g r o u n d C o l o r   G r a y 
 $ p   =   S t a r t - P r o c e s s   - W a i t   - P a s s T h r u   - N o N e w W i n d o w   m s i e x e c   - A r g u m e n t L i s t   $ a r g 
 $ e x i t C o d e   =   $ p . E x i t C o d e 
 
 i f   ( $ e x i t C o d e   - e q   0 )   { 
     S h o w - M e s s a g e B o x   " C y b e r N e t   A g e n t   i n s t a l a d o   e x i t o s a m e n t e . ` n ` n E l   a g e n t e   y a   e s t á   r e p o r t a n d o   a : ` n $ P l a t f o r m U r l "   " I n s t a l a c i ó n   C o m p l e t a " 
     W r i t e - H o s t   "     '  I n s t a l a c i ó n   e x i t o s a "   - F o r e g r o u n d C o l o r   G r e e n 
 }   e l s e i f   ( $ e x i t C o d e   - e q   3 0 1 0 )   { 
     S h o w - M e s s a g e B o x   " I n s t a l a c i ó n   c o m p l e t a d a .   R e q u i e r e   r e i n i c i o . "   " C y b e r N e t   A g e n t " 
     W r i t e - H o s t   "     '  I n s t a l a c i ó n   e x i t o s a   ( r e q u i e r e   r e i n i c i o ) "   - F o r e g r o u n d C o l o r   G r e e n 
 }   e l s e   { 
     $ e r r M s g   =   s w i t c h   ( $ e x i t C o d e )   { 
         1 6 0 1   {   " N o   s e   p u e d e   a c c e d e r   a l   i n s t a l a d o r   d e   W i n d o w s "   } 
         1 6 0 2   {   " I n s t a l a c i ó n   c a n c e l a d a   p o r   e l   u s u a r i o "   } 
         1 6 0 3   {   " E r r o r   f a t a l   d u r a n t e   l a   i n s t a l a c i ó n "   } 
         1 6 0 5   {   " E l   p r o d u c t o   n o   e s t á   i n s t a l a d o "   } 
         1 6 1 8   {   " O t r a   i n s t a l a c i ó n   e n   c u r s o "   } 
         1 6 2 2   {   " E r r o r   a l   a b r i r   e l   a r c h i v o   d e   o r i g e n "   } 
         1 6 4 1   {   " I n s t a l a c i ó n   c o m p l e t a d a   ( r e q u i e r e   r e i n i c i o ) "   } 
         d e f a u l t   {   " C ó d i g o   d e   e r r o r :   $ e x i t C o d e "   } 
     } 
     S h o w - M e s s a g e B o x   " E r r o r   d e   i n s t a l a c i ó n . ` n $ e r r M s g ` n ` n R e v i s a   E v e n t   V i e w e r   >   W i n d o w s   I n s t a l l e r   p a r a   m á s   d e t a l l e s . "   " E r r o r "   E r r o r 
     W r i t e - H o s t   "     '  E r r o r :   $ e x i t C o d e   -   $ e r r M s g "   - F o r e g r o u n d C o l o r   R e d 
 } 
 
 #    % %  L i m p i a r    % %
 R e m o v e - I t e m   $ m s i P a t h   - F o r c e   - E r r o r A c t i o n   S i l e n t l y C o n t i n u e 
 
 W r i t e - H o s t   " " 
 W r i t e - H o s t   " L o g :   $ e n v : T E M P \ c y b e r n e t - a g e n t . l o g "   - F o r e g r o u n d C o l o r   G r a y 
 W r i t e - H o s t   " = = =   F i n   = = = "   - F o r e g r o u n d C o l o r   C y a n 
 