Question
Importer ou intégrer variable dans un autre script
- Laurent
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 71
- Remerciements reçus 0
il y a 10 ans 1 mois #21638
par Laurent
Importer ou intégrer variable dans un autre script a été créé par Laurent
Bonjour à tous,
Petite question
J'ai une interface graphique Powershell en WPF avec un bouton installer.
Les script exemple 1, 2, 3, 4, 5, 6, fonctionnent séparément par contre quand je les mets les uns à la suite des autres dans l'événement de mon bouton \"installer\" seul le script exemple1.ps1 se lance et les autres ne se lance pas
Comment faire pour que quand le script example1.ps1 soit terminée le script example2.ps1 se lance
Merci à tous.
[code:1]#Events
$boutoninstaller.Add_Click({
.\..\SCRIPT\\"exemple1\" -Wait
.\..\SCRIPT\\"exemple2\" -Wait
.\..\SCRIPT\\"exemple3\" -Wait
.\..\SCRIPT\\"exemple4\" -Wait
.\..\SCRIPT\\"exemple5\" -Wait
.\..\SCRIPT\\"exemple6\" -Wait
})[/code:1][/code:1]
Message édité par: laurenzo34000, à: 4/04/16 15:50<br><br>Message édité par: laurenzo34000, à: 5/04/16 12:15
Petite question
J'ai une interface graphique Powershell en WPF avec un bouton installer.
Les script exemple 1, 2, 3, 4, 5, 6, fonctionnent séparément par contre quand je les mets les uns à la suite des autres dans l'événement de mon bouton \"installer\" seul le script exemple1.ps1 se lance et les autres ne se lance pas
Comment faire pour que quand le script example1.ps1 soit terminée le script example2.ps1 se lance
Merci à tous.
[code:1]#Events
$boutoninstaller.Add_Click({
.\..\SCRIPT\\"exemple1\" -Wait
.\..\SCRIPT\\"exemple2\" -Wait
.\..\SCRIPT\\"exemple3\" -Wait
.\..\SCRIPT\\"exemple4\" -Wait
.\..\SCRIPT\\"exemple5\" -Wait
.\..\SCRIPT\\"exemple6\" -Wait
})[/code:1][/code:1]
Message édité par: laurenzo34000, à: 4/04/16 15:50<br><br>Message édité par: laurenzo34000, à: 5/04/16 12:15
Pièces jointes :
Connexion ou Créer un compte pour participer à la conversation.
- Laurent
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 71
- Remerciements reçus 0
il y a 10 ans 1 mois #21642
par Laurent
Réponse de Laurent sur le sujet Importer ou intégrer variable dans un autre script
j'ai trouver la solution
[code:1]$emplacement = Split-Path $MyInvocation.MyCommand.path
powershell \"$emplacement\'exemple 1.ps1'\"
powershell \"$emplacement\'exemple 2.ps1'\"
powershell \"$emplacement\'exemple 3.ps1'\"
powershell \"$emplacement\'exemple 4.ps1'\"
powershell \"$emplacement\'exemple 5.ps1'\"[/code:1]
Par contre j'ai un nouveau soucis je souhaite intégrer mes variable contenu dans le script en cours \"application.ps1\" dans mes script exemple1.ps1 , exemple2.ps1, exemple3.ps1 ...
Merci pour votre aide<br><br>Message édité par: laurenzo34000, à: 5/04/16 12:15
[code:1]$emplacement = Split-Path $MyInvocation.MyCommand.path
powershell \"$emplacement\'exemple 1.ps1'\"
powershell \"$emplacement\'exemple 2.ps1'\"
powershell \"$emplacement\'exemple 3.ps1'\"
powershell \"$emplacement\'exemple 4.ps1'\"
powershell \"$emplacement\'exemple 5.ps1'\"[/code:1]
Par contre j'ai un nouveau soucis je souhaite intégrer mes variable contenu dans le script en cours \"application.ps1\" dans mes script exemple1.ps1 , exemple2.ps1, exemple3.ps1 ...
Merci pour votre aide<br><br>Message édité par: laurenzo34000, à: 5/04/16 12:15
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 10 ans 1 mois #21643
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:Importer ou intégrer variable dans un autre script
laurenzo34000 écrit:
Ta solution génère autant de contexte différent et cloisonnés que de script. Ce n'est pas possible comme tu le fais.
Mais il faut déjà trouver l'origine du pb pour proposer une solution...
N'ayant pas le code source du GUI, même de démo pour ton cas, ce n'est pas facile de t'aider. Est-ce donc à tes lecteurs/rices de recréer ce code ?Par contre j'ai un nouveau soucis je souhaite intégrer mes variable contenu dans le script en cours \"application.ps1\" dans mes script exemple1.ps1 , exemple2.ps1, exemple3.ps1 ...
Ta solution génère autant de contexte différent et cloisonnés que de script. Ce n'est pas possible comme tu le fais.
Mais il faut déjà trouver l'origine du pb pour proposer une solution...
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Laurent
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 71
- Remerciements reçus 0
il y a 10 ans 1 mois #21644
par Laurent
Réponse de Laurent sur le sujet Re:Importer ou intégrer variable dans un autre script
Excuse moi Laurent
Voici mon script Application.ps1 qui se trouve dans le même dossier que mon script 7 Zip.ps1
[code:1]#################################################################
# Chargement des Librairies
#################################################################
[Reflection.Assembly]::LoadWithPartialName(\"PresentationFramework\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"PresentationCore\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"WindowsBase\"«»)
[xml]$xaml = @\"
<Window
xmlns=\"schemas.microsoft.com/winfx/2006/xaml/presentation\"
xmlns:«»x=\"schemas.microsoft.com/winfx/2006/xaml\"
xmlns:d=\"schemas.microsoft.com/expression/blend/2008\"
xmlns:mc=\"schemas.openxmlformats.org/markup-compatibility/2006\"
xmlns:local=\"clr-namespace:WpfApplication2\"
Title=\"Installation et configuration \" Height=\"600\" Width=\"800\" ResizeMode=\"NoResize\" WindowStartupLocation=\"CenterScreen\">
<Grid>
<Button x:Name=\"installer\" Content=\"Installer\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"624,507,0,0\" VerticalAlignment=\"Top\" Width=\"112\" FontSize=\"16\" RenderTransformOrigin=\"0.527,2.586\"/>
<Button x:Name=\"quitter\" Content=\"Quitter\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"447,507,0,0\" VerticalAlignment=\"Top\" Width=\"112\" FontSize=\"16\"/>
<Label x:Name=\"label\" Content=\"7 Zip\" HorizontalAlignment=\"Left\" Margin=\"112,87,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy\" Content=\"Adobe Flash Player\" HorizontalAlignment=\"Left\" Margin=\"112,131,0,0\" VerticalAlignment=\"Top\" Width=\"155\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy1\" Content=\"Adobe Reader DC\" HorizontalAlignment=\"Left\" Margin=\"112,180,0,0\" VerticalAlignment=\"Top\" Width=\"155\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy2\" Content=\"CD Burner XP \" HorizontalAlignment=\"Left\" Margin=\"112,228,0,0\" VerticalAlignment=\"Top\" Width=\"115\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy3\" Content=\"Google Chrome \" HorizontalAlignment=\"Left\" Margin=\"112,280,0,0\" VerticalAlignment=\"Top\" Width=\"137\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy4\" Content=\"Java\" HorizontalAlignment=\"Left\" Margin=\"112,330,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy5\" Content=\"Libre Office\" HorizontalAlignment=\"Left\" Margin=\"112,376,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy6\" Content=\"Microsoft Office 2013\" HorizontalAlignment=\"Left\" Margin=\"428,87,0,0\" VerticalAlignment=\"Top\" Width=\"190\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy7\" Content=\"Mozilla Firefox\" HorizontalAlignment=\"Left\" Margin=\"428,131,0,0\" VerticalAlignment=\"Top\" Width=\"149\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy8\" Content=\"Mozilla Thunderbird\" HorizontalAlignment=\"Left\" Margin=\"428,180,0,0\" VerticalAlignment=\"Top\" Width=\"172\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy9\" Content=\"PDF Creator\" HorizontalAlignment=\"Left\" Margin=\"428,228,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\" RenderTransformOrigin=\"0.481,0.688\"/>
<Label x:Name=\"label_Copy10\" Content=\"Symantec Endpoint Protection\" HorizontalAlignment=\"Left\" Margin=\"428,280,0,0\" VerticalAlignment=\"Top\" Width=\"246\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy11\" Content=\"TeamViewer\" HorizontalAlignment=\"Left\" Margin=\"428,328,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy12\" Content=\"VLC\" HorizontalAlignment=\"Left\" Margin=\"428,376,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<TextBlock x:Name=\"installation\" HorizontalAlignment=\"Left\" Margin=\"40,32,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"707\" FontSize=\"16\"><Run Text=\"Pour installer et configurer votre ordinateur avec la liste des logiciels suivants cliquer sur Installer\"/><Run Text=\".\"/></TextBlock>
<TextBlock x:Name=\"encours\" HorizontalAlignment=\"Left\" Height=\"26\" Margin=\"40,462,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"707\" FontSize=\"16\" Text=\"\" Foreground=\"Red\"/>
<TextBlock x:Name=\"zip\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,87,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"flash\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,131,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"reader\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,180,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"burner\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,228,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"chrome\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,280,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\" RenderTransformOrigin=\"0.481,5.875\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"java\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,328,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"libre\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,376,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"office\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,87,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"firefox\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,131,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"thunderbird\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,180,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"creator\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,228,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"symantec\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,280,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"teamviewer\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,328,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"vlc\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,376,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
</Grid>
</Window>
\"@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )
#Connecter les controles
$boutoninstaller = $Window.FindName('installer')
$boutonquitter = $Window.Findname('quitter')
$encours = $Window.FindName('encours')
$zip = $Window.FindName('zip')
$flash = $Window.FindName('flash')
$reader = $Window.FindName('reader')
$burner = $Window.FindName('burner')
$chrome = $Window.FindName('chrome')
$java = $Window.FindName('java')
$libre = $Window.FindName('libre')
$office = $Window.FindName('office')
$firefox = $Window.FindName('firefox')
$thunderbird = $Window.FindName('thunderbird')
$creator = $Window.FindName('creator')
$symantec = $Window.FindName('symantec')
$teamviewer = $Window.FindName('teamviewer')
$vlc = $Window.FindName('vlc')
$emplacement = Split-Path $MyInvocation.MyCommand.path
$chemin = Split-Path $emplacement -Parent
#Events
$boutoninstaller.Add_Click({
powershell \"$emplacement\'7 Zip.ps1'\" -Wait
powershell \"$emplacement\'Adobe Reader DC'\" -Wait
})
$boutonquitter.Add_Click(
{
$Window.Close()
})
$Window.ShowDialog() | Out-Null
[/code:1]
Voici mon script 7 Zip.ps1 celui ci contient une variable contenu dans mon fichier Application.ps1 qui permet de changer ma GUI après l'exécution de la commande pour dire que l'opération c'est bien déroulée
Je souhaiterais donc \"importer ou integrer\" les variables Application.ps1 dans mon script 7 Zip.ps1 pour que les variable zip change ma GUI j'espère que c'est pas trop brouillon comme explication.
(Le script 7 Zip fonctionne)
[code:1]# Site internet
# www.7-zip.org/download.html
if ([intptr]::«»size -eq 8)
{
write-output '64 bits'
cd \"..\LOGICIEL\7 ZIP\"
Start-Process \"7z1514-x64.exe\" /S -Wait
$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)
}
elseif ([intptr]::«»size -eq 4)
{
write-output '32 bits'
cd \"..\LOGICIEL\7 ZIP\"
Start-Process \"7z1514-x32.exe\" /S -Wait
$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)
}
[/code:1]<br><br>Message édité par: laurenzo34000, à: 5/04/16 13:30
Voici mon script Application.ps1 qui se trouve dans le même dossier que mon script 7 Zip.ps1
[code:1]#################################################################
# Chargement des Librairies
#################################################################
[Reflection.Assembly]::LoadWithPartialName(\"PresentationFramework\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"PresentationCore\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"WindowsBase\"«»)
[xml]$xaml = @\"
<Window
xmlns=\"schemas.microsoft.com/winfx/2006/xaml/presentation\"
xmlns:«»x=\"schemas.microsoft.com/winfx/2006/xaml\"
xmlns:d=\"schemas.microsoft.com/expression/blend/2008\"
xmlns:mc=\"schemas.openxmlformats.org/markup-compatibility/2006\"
xmlns:local=\"clr-namespace:WpfApplication2\"
Title=\"Installation et configuration \" Height=\"600\" Width=\"800\" ResizeMode=\"NoResize\" WindowStartupLocation=\"CenterScreen\">
<Grid>
<Button x:Name=\"installer\" Content=\"Installer\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"624,507,0,0\" VerticalAlignment=\"Top\" Width=\"112\" FontSize=\"16\" RenderTransformOrigin=\"0.527,2.586\"/>
<Button x:Name=\"quitter\" Content=\"Quitter\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"447,507,0,0\" VerticalAlignment=\"Top\" Width=\"112\" FontSize=\"16\"/>
<Label x:Name=\"label\" Content=\"7 Zip\" HorizontalAlignment=\"Left\" Margin=\"112,87,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy\" Content=\"Adobe Flash Player\" HorizontalAlignment=\"Left\" Margin=\"112,131,0,0\" VerticalAlignment=\"Top\" Width=\"155\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy1\" Content=\"Adobe Reader DC\" HorizontalAlignment=\"Left\" Margin=\"112,180,0,0\" VerticalAlignment=\"Top\" Width=\"155\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy2\" Content=\"CD Burner XP \" HorizontalAlignment=\"Left\" Margin=\"112,228,0,0\" VerticalAlignment=\"Top\" Width=\"115\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy3\" Content=\"Google Chrome \" HorizontalAlignment=\"Left\" Margin=\"112,280,0,0\" VerticalAlignment=\"Top\" Width=\"137\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy4\" Content=\"Java\" HorizontalAlignment=\"Left\" Margin=\"112,330,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy5\" Content=\"Libre Office\" HorizontalAlignment=\"Left\" Margin=\"112,376,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy6\" Content=\"Microsoft Office 2013\" HorizontalAlignment=\"Left\" Margin=\"428,87,0,0\" VerticalAlignment=\"Top\" Width=\"190\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy7\" Content=\"Mozilla Firefox\" HorizontalAlignment=\"Left\" Margin=\"428,131,0,0\" VerticalAlignment=\"Top\" Width=\"149\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy8\" Content=\"Mozilla Thunderbird\" HorizontalAlignment=\"Left\" Margin=\"428,180,0,0\" VerticalAlignment=\"Top\" Width=\"172\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy9\" Content=\"PDF Creator\" HorizontalAlignment=\"Left\" Margin=\"428,228,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\" RenderTransformOrigin=\"0.481,0.688\"/>
<Label x:Name=\"label_Copy10\" Content=\"Symantec Endpoint Protection\" HorizontalAlignment=\"Left\" Margin=\"428,280,0,0\" VerticalAlignment=\"Top\" Width=\"246\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy11\" Content=\"TeamViewer\" HorizontalAlignment=\"Left\" Margin=\"428,328,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<Label x:Name=\"label_Copy12\" Content=\"VLC\" HorizontalAlignment=\"Left\" Margin=\"428,376,0,0\" VerticalAlignment=\"Top\" Width=\"108\" FontSize=\"16\" Height=\"32\"/>
<TextBlock x:Name=\"installation\" HorizontalAlignment=\"Left\" Margin=\"40,32,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"707\" FontSize=\"16\"><Run Text=\"Pour installer et configurer votre ordinateur avec la liste des logiciels suivants cliquer sur Installer\"/><Run Text=\".\"/></TextBlock>
<TextBlock x:Name=\"encours\" HorizontalAlignment=\"Left\" Height=\"26\" Margin=\"40,462,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"707\" FontSize=\"16\" Text=\"\" Foreground=\"Red\"/>
<TextBlock x:Name=\"zip\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,87,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"flash\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,131,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"reader\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,180,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"burner\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,228,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"chrome\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,280,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\" RenderTransformOrigin=\"0.481,5.875\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"java\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,328,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"libre\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"80,376,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"office\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,87,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"firefox\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,131,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"thunderbird\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,180,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"creator\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,228,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"symantec\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,280,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"teamviewer\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,328,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
<TextBlock x:Name=\"vlc\" HorizontalAlignment=\"Left\" Height=\"32\" Margin=\"396,376,0,0\" TextWrapping=\"Wrap\" VerticalAlignment=\"Top\" Width=\"27\" FontSize=\"29.333\"><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\"S\"/><Run Foreground=\"Red\" FontFamily=\"Wingdings 2\" Text=\" \"/></TextBlock>
</Grid>
</Window>
\"@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )
#Connecter les controles
$boutoninstaller = $Window.FindName('installer')
$boutonquitter = $Window.Findname('quitter')
$encours = $Window.FindName('encours')
$zip = $Window.FindName('zip')
$flash = $Window.FindName('flash')
$reader = $Window.FindName('reader')
$burner = $Window.FindName('burner')
$chrome = $Window.FindName('chrome')
$java = $Window.FindName('java')
$libre = $Window.FindName('libre')
$office = $Window.FindName('office')
$firefox = $Window.FindName('firefox')
$thunderbird = $Window.FindName('thunderbird')
$creator = $Window.FindName('creator')
$symantec = $Window.FindName('symantec')
$teamviewer = $Window.FindName('teamviewer')
$vlc = $Window.FindName('vlc')
$emplacement = Split-Path $MyInvocation.MyCommand.path
$chemin = Split-Path $emplacement -Parent
#Events
$boutoninstaller.Add_Click({
powershell \"$emplacement\'7 Zip.ps1'\" -Wait
powershell \"$emplacement\'Adobe Reader DC'\" -Wait
})
$boutonquitter.Add_Click(
{
$Window.Close()
})
$Window.ShowDialog() | Out-Null
[/code:1]
Voici mon script 7 Zip.ps1 celui ci contient une variable contenu dans mon fichier Application.ps1 qui permet de changer ma GUI après l'exécution de la commande pour dire que l'opération c'est bien déroulée
Je souhaiterais donc \"importer ou integrer\" les variables Application.ps1 dans mon script 7 Zip.ps1 pour que les variable zip change ma GUI j'espère que c'est pas trop brouillon comme explication.
(Le script 7 Zip fonctionne)
[code:1]# Site internet
# www.7-zip.org/download.html
if ([intptr]::«»size -eq 8)
{
write-output '64 bits'
cd \"..\LOGICIEL\7 ZIP\"
Start-Process \"7z1514-x64.exe\" /S -Wait
$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)
}
elseif ([intptr]::«»size -eq 4)
{
write-output '32 bits'
cd \"..\LOGICIEL\7 ZIP\"
Start-Process \"7z1514-x32.exe\" /S -Wait
$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)
}
[/code:1]<br><br>Message édité par: laurenzo34000, à: 5/04/16 13:30
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 10 ans 1 mois #21652
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:Importer ou intégrer variable dans un autre script
laurenzo34000 écrit:
Avant de regarder de + près (si j'ai le temps), peux-tu tester en forçant la 'location' (le path courant de PS) ou utiliser des nom de chemin complet avant d'appeler tes scripts.<br><br>Message édité par: Laurent Dardenne, à: 5/04/16 15:38
Pas de soucis, prends la peine de te mettre à la place de celui qui lira ton post.Excuse moi Laurent
Avant de regarder de + près (si j'ai le temps), peux-tu tester en forçant la 'location' (le path courant de PS) ou utiliser des nom de chemin complet avant d'appeler tes scripts.<br><br>Message édité par: Laurent Dardenne, à: 5/04/16 15:38
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- Laurent
- Auteur du sujet
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 71
- Remerciements reçus 0
il y a 10 ans 1 mois #21660
par Laurent
Réponse de Laurent sur le sujet Re:Importer ou intégrer variable dans un autre script
Erreur du débutant le chemin de retour du script n'était pas correct.
Je dois donc rajouter
[code:1]Set-location \"$emplacement\"[/code:1]
entre chaque exécution de script
Le seul petit bémol mes variables $zip $flash $reader
[code:1]$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)[/code:1]
sont effectué à la fin de tous les scripts et non pas à la fin de chaque script ce qui me permettrai de savoir en temps réel si le logiciel Adobe reader est bien installé.
Une petite aide ?
Encore merci à tous
Je dois donc rajouter
[code:1]Set-location \"$emplacement\"[/code:1]
entre chaque exécution de script
Le seul petit bémol mes variables $zip $flash $reader
[code:1]$zip.FontFamily =(\"Wingdings 2\"«»)
$zip.Text = (\"R\"«»)
$zip.Foreground = (\"Green\"«»)[/code:1]
sont effectué à la fin de tous les scripts et non pas à la fin de chaque script ce qui me permettrai de savoir en temps réel si le logiciel Adobe reader est bien installé.
Une petite aide ?
Encore merci à tous
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.052 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Importer ou intégrer variable dans un autre script