Instal_edeiaLab.psm1
|
<#
.Synopsis Instalar e-DeiaLab em um terminal .DESCRIPTION Este modulo instalada o e-DeiaLab num terminal juntamente com todas as ferramentas necessárias .EXAMPLE get-eDeiaLab -DrDestino c:\edeia -Servidor=192.168.1.1 .EXAMPLE get-eDeiaLab -DrDestino c:\edeia -Servidor=Servidor #> function get-eDeiaLab { [CmdletBinding()] Param ( # Diretorio local onde sera instalado e-DeiaLab c:\edeia [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] $DirDestino="c:\edeiax", [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=1)] # IP ou DNS do servidor onde está o e-DeiaLab $Servidor="192.168.111.3" ) Begin { } Process { #$DirDestino="c:\edeiax" #$Servidor="192.168.111.3" # testar se existe o diretorio e se não criar if (-not(Test-Path -Path $DirDestino)) { Write-Verbose "Criar diretório $DirDestino" New-Item -Path $DirDestino -ItemType Directory } # descarregar o necessário do servidor cliente ou remoto $filelocal="menulab.exe" Write-Verbose "Download file http://$servidor/edeia/$filelocal para $DirDestino\$filelocal" Start-BitsTransfer -Source "http://$servidor/edeia/$filelocal" -Destination "$DirDestino\$filelocal" $fileremoto="syncfusion.tools.dll", "Syncfusion.Grid.dll", "Syncfusion.Shared.dll", "Menulab.xml" foreach ($f in $fileremoto) { Write-Verbose "Download file http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f para $DirDestino\$f" Start-BitsTransfer -Source "http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f" -Destination "$DirDestino\$f" #Write-Output "http://192.168.111.1/edeia/tools/InstalacaoLocal/$f" } #abrir o menulab.xml para definir o servidor $fileMenulab_xml="$DirDestino\menulab.xml" if (Test-Path -Path $fileMenulab_xml) { Write-Verbose "Editar menulab.xml" [xml]$XmlDocument = Get-Content -Path $fileMenulab_xml $XmlDocument.Configuracao.UrlServidor="http://$Servidor/edeia/" $XmlDocument.Save($fileMenulab_xml) } #testar se 64 se 32 $32_ou_64=(Get-WmiObject Win32_OperatingSystem).OSArchitecture #Instalar o .net4.0 $f="dotNetFx40_Full_x86_x64.exe" if (-not (Test-Path -Path "$DirDestino\$f")) { Write-Verbose "Download .net framework 4" Start-BitsTransfer -Source "http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/$f" -Destination "$DirDestino\$f" } Write-Verbose "Instalar .net framework 4" Start-Process -FilePath "$DirDestino\$f" -ArgumentList "/q /norestart" -wait $f="" #instalar o crystal if ( $32_ou_64.StartsWith("64")) { #instalar 64 bits $fileremoto="Crystal_V10.x64.msi", "CRRuntime_64bit_13_0_8.msi" foreach ($f in $fileremoto) { if (-not (Test-Path -Path "$DirDestino\$f")) { Write-Verbose "Download http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f para $DirDestino\$f" Start-BitsTransfer -Source "http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f" -Destination "$DirDestino\$f" } #Write-Output "http://192.168.111.1/edeia/tools/InstalacaoLocal/$f" # deploy Crystal Reports Write-Verbose "Instalar $DirDestino\$f" Start-Process "$DirDestino\$f" /qn -Wait -Verbose } } else { #instalar 32 bits $fileremoto="Crystal_V10.x86.msi", "CRRuntime_32bit_13_0_8.msi" foreach ($f in $fileremoto) { if (-not (Test-Path -Path "$DirDestino\$f")) { Write-Verbose "Download http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f para $DirDestino\$f" Start-BitsTransfer -Source "http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f" -Destination "$DirDestino\$f" } # deploy Crystal Reports Write-Verbose "Instalar $DirDestino\$f" Start-Process "$DirDestino\$f" /qn -Wait -Verbose } } #Criar atalho ambiente de trabalho $WshShell = New-Object -comObject WScript.Shell $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\e-DeiaLab.lnk") $Shortcut.TargetPath = "$DirDestino\menulab.exe" $Shortcut.Save() #copiar fonte cod-39 $f="Code-39-20.ttf" Write-Verbose "Download Font e instalar $DirDestino\$f" Start-BitsTransfer -Source "http://segilac.no-ip.org/edeia/tools/InstalacaoLocal/$f" -Destination "$DirDestino\$f" $FONTS = 0x14 $Path="$env:SystemRoot\Fonts\$f" $objShell = New-Object -ComObject Shell.Application $objFolder = $objShell.Namespace($FONTS) foreach($File in $Fontdir) { $objFolder.CopyHere($File.fullname) } #Arrancar com o e-DeiaLab Start-Process "$DirDestino\menulab.exe" Write-Verbose "Instalação terminada" } End { } } |