xs4eyes

Install programs

May 13th, 2016
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  ############################################
  2.  #
  3.  # Installing fonts is a bit different, read
  4.  # script .
  5.  # $FromPath is the location of the fonts
  6.  #
  7.  ############################################
  8.  
  9.  
  10.     Function install-fonts{
  11.       $FONTS = 0x14
  12.       $FromPath="location of font files"
  13.  
  14.       $objShell = New-Object -ComObject Shell.Application
  15.       $objFolder = $objShell.Namespace($FONTS)
  16.  
  17.       $CopyOptions = 4 + 16
  18.       $CopyFlag = [String]::Format("{0:x}", $CopyOptions)
  19.  
  20.  
  21.       foreach($File in $(Ls $Frompath)) {
  22.         If (test-path "c:\windows\fonts\$($file.name)")
  23.         {"Font already exists - not copying"}  #Useful for testing
  24.         Else
  25.         {
  26.           $copyFlag = [String]::Format("{0:x}", $CopyOptions)
  27.           "copying $($file.fullname)"           # Useful for debugging
  28.           $objFolder.CopyHere($File.fullname, $CopyOptions)
  29.         }
  30.       }
  31.     }
  32.  
  33.  function Convert-XAMLtoWindow
  34.  {
  35.    param
  36.    (
  37.      [Parameter(Mandatory=$true)]
  38.      [string]
  39.      $XAML,
  40.    
  41.      [string[]]
  42.      $NamedElements,
  43.    
  44.      [switch]
  45.      $PassThru
  46.    )
  47.  
  48.    Add-Type -AssemblyName PresentationFramework
  49.  
  50.    $reader = [System.XML.XMLReader]::Create([System.IO.StringReader]$XAML)
  51.    $result = [System.Windows.Markup.XAMLReader]::Load($reader)
  52.    foreach($Name in $NamedElements)
  53.    {
  54.      $result | Add-Member NoteProperty -Name $Name -Value $result.FindName($Name) -Force
  55.    }
  56.  
  57.    if ($PassThru)
  58.    {
  59.      $result
  60.    }
  61.    else
  62.    {
  63.      $result.ShowDialog()
  64.    }
  65.  }
  66.  
  67.  $xaml = @'
  68. <Window
  69.   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  70.   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  71.   MinHeight="350"
  72.   Width="525"
  73.   SizeToContent="Height"
  74.   Title="PowerShell WPF Window"
  75.   Topmost="True">
  76.    <Grid>
  77.        <Grid.ColumnDefinitions>
  78.            <ColumnDefinition Width="30*"/>
  79.            <ColumnDefinition Width="30*"/>
  80.            <ColumnDefinition Width="30*"/>
  81.        </Grid.ColumnDefinitions>
  82.        <Grid.RowDefinitions>
  83.            <RowDefinition Height="20*"/>
  84.            <RowDefinition Height="Auto"/>
  85.            <RowDefinition Height="20*"/>
  86.        </Grid.RowDefinitions>
  87.        <TextBlock
  88.         x:Name="TextMessag"
  89.         HorizontalAlignment="Center"
  90.         VerticalAlignment="Center"
  91.         FontFamily="Consolas"
  92.         FontSize="20"
  93.         FontWeight="Bold"
  94.         Foreground="Blue" Margin="149,10,152,126" Text=" Software Installer" Grid.ColumnSpan="3" Width="216"/>
  95.        <Button
  96.         Name="Done"
  97.         Width="80"
  98.         Height="25"
  99.         Grid.Column="2"
  100.         Grid.Row="2"
  101.         HorizontalAlignment="Right"
  102.         Margin="10"
  103.         VerticalAlignment="Bottom">Done
  104.        </Button>
  105.        <Button x:Name="Ninite" Content="7FB" HorizontalAlignment="Left" Margin="10,59,0,0" VerticalAlignment="Top" Width="152"/>
  106.        <Button x:Name="McAfee" Content="McAfee" HorizontalAlignment="Left" Margin="10,84,0,0" VerticalAlignment="Top" Width="152"/>
  107.        <Button x:Name="Visual" Content="Visual" HorizontalAlignment="Left" Margin="10,109,0,0" VerticalAlignment="Top" Width="152"/>
  108.        <Button x:Name="Fonts" Content="Fonts" HorizontalAlignment="Left" Margin="10,134,0,0" Grid.RowSpan="2" VerticalAlignment="Top" Width="152" RenderTransformOrigin="-0.473,-1.238"/>
  109.        <Button x:Name="Office" Content="Microsoft Office" HorizontalAlignment="Left" Margin="10,159,0,0" VerticalAlignment="Top" Width="152" Grid.RowSpan="3"/>
  110.        <Button x:Name="Activate" Content="Activate Windows" HorizontalAlignment="Left" Margin="10,24,0,0" Grid.Row="2" VerticalAlignment="Top" Width="152"/>
  111.    </Grid>
  112. </Window>
  113. '@
  114.  
  115.  $window = Convert-XAMLtoWindow -XAML $xaml -NamedElements 'TextMessag', 'Done', 'Ninite', 'McAfee', 'Visual', 'Fonts', 'Office', 'Activate' -PassThru
  116.  
  117.  
  118.  $window.Ninite.add_Click(
  119.    {invoke-item "Location to ninite installer.exe"
  120.      [System.Object]$sender = $args[0]
  121.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  122.    
  123.    }
  124.  )
  125.  
  126.  
  127.  
  128.  
  129.  $window.Fonts.add_Click(
  130.    {
  131.      Install-fonts
  132.    
  133.    
  134.      [System.Object]$sender = $args[0]
  135.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  136.    
  137.    }
  138.  )
  139.  
  140.  
  141.  ##############################
  142.  # Opens the web page to
  143.  # activate windows
  144.  #
  145.  #############################
  146.  
  147.  
  148.  $window.Activate.add_Click(
  149.    {
  150.      Start-Process -FilePath "https://microsoft.gointeract.io/mobileweb/?interaction=1443478049354-2924fcb582254ed49836617882f915015fecd10-64be&accountId=microsoft&appkey=fdd66706-ae19-4524-a9e5-440df6739dcd&Language=English&name=pana&Click%20To%20Call%20Caller%20Id=+13086272915&dnis=24"
  151.      [System.Object]$sender = $args[0]
  152.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  153.    
  154.    }
  155.  )
  156.  
  157.  
  158.  
  159.  
  160.  $window.Office.add_Click(
  161.    {
  162.      Explorer "Opens folder to office install files"
  163.      Explorer "Opens folder to location of stored keys"
  164.    
  165.      [System.Object]$sender = $args[0]
  166.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  167.    
  168.    }
  169.  )
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  $window.Visual.add_Click(
  177.    {
  178.      Invoke-Item "install file.bat"
  179.      Invoke-Item "install file.cmd"
  180.      Invoke-Item "install file.bat"
  181.  
  182.      Invoke-Item "install file.exe"
  183.    
  184.      [System.Object]$sender = $args[0]
  185.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  186.    
  187.    }
  188.  )
  189.  
  190.  # this is a .lnk so we can update the installer with ease
  191.  
  192.  $window.McAfee.add_Click(
  193.    {
  194.      invoke-item "install file.lnk"
  195.      invoke-item "install file.lnk"
  196.      [System.Object]$sender = $args[0]
  197.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  198.    
  199.    }
  200.  )
  201.  
  202.  
  203.  
  204.  
  205.  $window.Done.add_Click(
  206.    {
  207.      $window.Close()
  208.      [System.Object]$sender = $args[0]
  209.      [System.Windows.RoutedEventArgs]$e = $args[1]  
  210.    
  211.    }
  212.  )
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  $window.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment