Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################################
- #
- # Installing fonts is a bit different, read
- # script .
- # $FromPath is the location of the fonts
- #
- ############################################
- Function install-fonts{
- $FONTS = 0x14
- $FromPath="location of font files"
- $objShell = New-Object -ComObject Shell.Application
- $objFolder = $objShell.Namespace($FONTS)
- $CopyOptions = 4 + 16
- $CopyFlag = [String]::Format("{0:x}", $CopyOptions)
- foreach($File in $(Ls $Frompath)) {
- If (test-path "c:\windows\fonts\$($file.name)")
- {"Font already exists - not copying"} #Useful for testing
- Else
- {
- $copyFlag = [String]::Format("{0:x}", $CopyOptions)
- "copying $($file.fullname)" # Useful for debugging
- $objFolder.CopyHere($File.fullname, $CopyOptions)
- }
- }
- }
- function Convert-XAMLtoWindow
- {
- param
- (
- [Parameter(Mandatory=$true)]
- [string]
- $XAML,
- [string[]]
- $NamedElements,
- [switch]
- $PassThru
- )
- Add-Type -AssemblyName PresentationFramework
- $reader = [System.XML.XMLReader]::Create([System.IO.StringReader]$XAML)
- $result = [System.Windows.Markup.XAMLReader]::Load($reader)
- foreach($Name in $NamedElements)
- {
- $result | Add-Member NoteProperty -Name $Name -Value $result.FindName($Name) -Force
- }
- if ($PassThru)
- {
- $result
- }
- else
- {
- $result.ShowDialog()
- }
- }
- $xaml = @'
- <Window
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- MinHeight="350"
- Width="525"
- SizeToContent="Height"
- Title="PowerShell WPF Window"
- Topmost="True">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="30*"/>
- <ColumnDefinition Width="30*"/>
- <ColumnDefinition Width="30*"/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="20*"/>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="20*"/>
- </Grid.RowDefinitions>
- <TextBlock
- x:Name="TextMessag"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- FontFamily="Consolas"
- FontSize="20"
- FontWeight="Bold"
- Foreground="Blue" Margin="149,10,152,126" Text=" Software Installer" Grid.ColumnSpan="3" Width="216"/>
- <Button
- Name="Done"
- Width="80"
- Height="25"
- Grid.Column="2"
- Grid.Row="2"
- HorizontalAlignment="Right"
- Margin="10"
- VerticalAlignment="Bottom">Done
- </Button>
- <Button x:Name="Ninite" Content="7FB" HorizontalAlignment="Left" Margin="10,59,0,0" VerticalAlignment="Top" Width="152"/>
- <Button x:Name="McAfee" Content="McAfee" HorizontalAlignment="Left" Margin="10,84,0,0" VerticalAlignment="Top" Width="152"/>
- <Button x:Name="Visual" Content="Visual" HorizontalAlignment="Left" Margin="10,109,0,0" VerticalAlignment="Top" Width="152"/>
- <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"/>
- <Button x:Name="Office" Content="Microsoft Office" HorizontalAlignment="Left" Margin="10,159,0,0" VerticalAlignment="Top" Width="152" Grid.RowSpan="3"/>
- <Button x:Name="Activate" Content="Activate Windows" HorizontalAlignment="Left" Margin="10,24,0,0" Grid.Row="2" VerticalAlignment="Top" Width="152"/>
- </Grid>
- </Window>
- '@
- $window = Convert-XAMLtoWindow -XAML $xaml -NamedElements 'TextMessag', 'Done', 'Ninite', 'McAfee', 'Visual', 'Fonts', 'Office', 'Activate' -PassThru
- $window.Ninite.add_Click(
- {invoke-item "Location to ninite installer.exe"
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- $window.Fonts.add_Click(
- {
- Install-fonts
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- ##############################
- # Opens the web page to
- # activate windows
- #
- #############################
- $window.Activate.add_Click(
- {
- 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"
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- $window.Office.add_Click(
- {
- Explorer "Opens folder to office install files"
- Explorer "Opens folder to location of stored keys"
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- $window.Visual.add_Click(
- {
- Invoke-Item "install file.bat"
- Invoke-Item "install file.cmd"
- Invoke-Item "install file.bat"
- Invoke-Item "install file.exe"
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- # this is a .lnk so we can update the installer with ease
- $window.McAfee.add_Click(
- {
- invoke-item "install file.lnk"
- invoke-item "install file.lnk"
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- $window.Done.add_Click(
- {
- $window.Close()
- [System.Object]$sender = $args[0]
- [System.Windows.RoutedEventArgs]$e = $args[1]
- }
- )
- $window.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment