IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Scripts/Batch Discussion :

Recherche d'un programme dans la base de registre [PowerShell]


Sujet :

Scripts/Batch

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2010
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2010
    Messages : 15
    Points : 14
    Points
    14
    Par défaut Recherche d'un programme dans la base de registre
    Bonjour,

    Je suis un débutant en PowerShell. J'ai développé rapidement une application pour la boite d'info dans laquelle je fais mon stage. Je vous la présente :

    Cette application à pour but de faire gagner du temps aux personnes qui configure pour un démarrage de base une nouvelle machine sous Win7 Pro.
    Ce que l'on recherche c'est de supprimer eBay, Google Toolbar et Norton en quelques click tout en s'assurant que ce n'est pas déjà fait. Puis d'installer rapidement OpenOffice, DoPDF, Microsoft Security Essentials et quelques raccourcis sur le bureau.

    J'ai aujourd'hui un version totalement graphique de mon application grâce au logiciel PrimalForms Community Edition qui m'a permis en quelques minutes de formater cet affichage :



    Cependant je souhaiterai ajouté un label en face de chacun des boutons pour afficher si c'est installé ou pas sur la machine.
    Je pensais faire cela avec un traitement sur les clés de registre Uninstall vu qu'elles englobent l'ensemble des programmes installés. Cependant je ne sais pas comment je doit traiter cette information.

    Je vous rajoute mon script:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
     
     
    $Chemin_Execution_Script = $PWD
     
    #Generated Form Function
    function GenerateForm {
    ########################################################################
    # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.9.0
    # Generated On: 23/05/2011 11:10
    # Generated By: Maxime.llas
    ########################################################################
     
    #region Import the Assemblies
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    #endregion
     
    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $Raccourci_IE = New-Object System.Windows.Forms.Button
    $Microsoft_Security = New-Object System.Windows.Forms.Button
    $DoPDF = New-Object System.Windows.Forms.Button
    $Open_Office = New-Object System.Windows.Forms.Button
    $label2 = New-Object System.Windows.Forms.Label
    $Norton = New-Object System.Windows.Forms.Button
    $Google_Toolbar = New-Object System.Windows.Forms.Button
    $eBay = New-Object System.Windows.Forms.Button
    $label1 = New-Object System.Windows.Forms.Label
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
     
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
     
    $DoPDF_OnClick= 
    {
    #TODO: Place custom script here
    Set-Location $Chemin_Execution_Script
    Invoke-Item dopdf-7.exe
     
    $strShtCut = "\dopdf.lnk"
    $Shortcut = New-Object -ComObject WScript.Shell
    $DesktopPath = $Shortcut.SpecialFolders.Item("Desktop")
    $ShtCut = $Shortcut.CreateShortcut($DesktopPath + $strShtCut)
    $ShtCut.TargetPath = "C:\Program Files\Softland\doPDF 7\dopdf.exe"
    $ShtCut.Save()
    }
     
    $Raccourci_IE_OnClick= 
    {
    #TODO: Place custom script here
    $strShtCut = "\Internet Explorer.lnk"
    $Shortcut = New-Object -ComObject WScript.Shell
    $DesktopPath = $Shortcut.SpecialFolders.Item("Desktop")
    $ShtCut = $Shortcut.CreateShortcut($DesktopPath + $strShtCut)
    $ShtCut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
    $ShtCut.Save()
    }
     
    $Norton_OnClick= 
    {
    #TODO: Place custom script here
    Set-Location "C:\Program Files\NortonInstaller\{0C55C096-0F1D-4F28-AAA2-85EF591126E7}\NIS\A5E82D02\17.0.0.136"
    Invoke-Expression ".\InstStub.exe /x"
    }
     
    $Microsoft_Security_OnClick= 
    {
    #TODO: Place custom script here
    Set-Location $Chemin_Execution_Script
    Invoke-Item Microsoft_Security_Essentials.exe
    }
     
    $Google_Toolbar_OnClick= 
    {
    #TODO: Place custom script here
    Set-Location "C:\Program Files\Google\Google Toolbar\Component"
    Invoke-Expression ".\GoogleToolbarManager_1E79ECA290B62A66.exe /uninstall"
    }
     
    $Open_Office_OnClick= 
    {
    #TODO: Place custom script here
    Set-Location $Chemin_Execution_Script
    Invoke-Item OpenOffice_3.3.0_install_fr.exe
    }
     
    $eBay_OnClick= 
    {
    #TODO: Place custom script here
    Invoke-Expression "C:\windows\system32\MsiExec.exe /X C:\windows\installer\2bf2b.msi"
    }
     
    $handler_label1_Click= 
    {
    #TODO: Place custom script here
     
    }
     
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
        $form1.WindowState = $InitialFormWindowState
    }
     
    #----------------------------------------------
    #region Generated Form Code
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 351
    $System_Drawing_Size.Width = 361
    $form1.ClientSize = $System_Drawing_Size
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $form1.Name = "form1"
    $form1.Text = "Utilitaire de démarrage rapide"
     
     
    $Raccourci_IE.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 13
    $System_Drawing_Point.Y = 316
    $Raccourci_IE.Location = $System_Drawing_Point
    $Raccourci_IE.Name = "Raccourci_IE"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 336
    $Raccourci_IE.Size = $System_Drawing_Size
    $Raccourci_IE.TabIndex = 8
    $Raccourci_IE.Text = "Ajouter le raccourci Internet Explorer au Bureau"
    $Raccourci_IE.UseVisualStyleBackColor = $True
    $Raccourci_IE.add_Click($Raccourci_IE_OnClick)
     
    $form1.Controls.Add($Raccourci_IE)
     
     
    $Microsoft_Security.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 81
    $System_Drawing_Point.Y = 227
    $Microsoft_Security.Location = $System_Drawing_Point
    $Microsoft_Security.Name = "Microsoft_Security"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 180
    $Microsoft_Security.Size = $System_Drawing_Size
    $Microsoft_Security.TabIndex = 7
    $Microsoft_Security.Text = "Microsoft Security Essentials"
    $Microsoft_Security.UseVisualStyleBackColor = $True
    $Microsoft_Security.add_Click($Microsoft_Security_OnClick)
     
    $form1.Controls.Add($Microsoft_Security)
     
     
    $DoPDF.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 81
    $System_Drawing_Point.Y = 198
    $DoPDF.Location = $System_Drawing_Point
    $DoPDF.Name = "DoPDF"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 181
    $DoPDF.Size = $System_Drawing_Size
    $DoPDF.TabIndex = 6
    $DoPDF.Text = "DoPDF"
    $DoPDF.UseVisualStyleBackColor = $True
    $DoPDF.add_Click($DoPDF_OnClick)
     
    $form1.Controls.Add($DoPDF)
     
     
    $Open_Office.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 81
    $System_Drawing_Point.Y = 169
    $Open_Office.Location = $System_Drawing_Point
    $Open_Office.Name = "Open_Office"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 180
    $Open_Office.Size = $System_Drawing_Size
    $Open_Office.TabIndex = 5
    $Open_Office.Text = "Open Office"
    $Open_Office.UseVisualStyleBackColor = $True
    $Open_Office.add_Click($Open_Office_OnClick)
     
    $form1.Controls.Add($Open_Office)
     
    $label2.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 121
    $System_Drawing_Point.Y = 143
    $label2.Location = $System_Drawing_Point
    $label2.Name = "label2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 100
    $label2.Size = $System_Drawing_Size
    $label2.TabIndex = 4
    $label2.Text = "Installation"
     
    $form1.Controls.Add($label2)
     
     
    $Norton.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 93
    $System_Drawing_Point.Y = 93
    $Norton.Location = $System_Drawing_Point
    $Norton.Name = "Norton"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 145
    $Norton.Size = $System_Drawing_Size
    $Norton.TabIndex = 3
    $Norton.Text = "Norton Internet Security"
    $Norton.UseVisualStyleBackColor = $True
    $Norton.add_Click($Norton_OnClick)
     
    $form1.Controls.Add($Norton)
     
     
    $Google_Toolbar.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 93
    $System_Drawing_Point.Y = 64
    $Google_Toolbar.Location = $System_Drawing_Point
    $Google_Toolbar.Name = "Google_Toolbar"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 145
    $Google_Toolbar.Size = $System_Drawing_Size
    $Google_Toolbar.TabIndex = 2
    $Google_Toolbar.Text = "Google Toolbar"
    $Google_Toolbar.UseVisualStyleBackColor = $True
    $Google_Toolbar.add_Click($Google_Toolbar_OnClick)
     
    $form1.Controls.Add($Google_Toolbar)
     
     
    $eBay.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 93
    $System_Drawing_Point.Y = 35
    $eBay.Location = $System_Drawing_Point
    $eBay.Name = "eBay"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 145
    $eBay.Size = $System_Drawing_Size
    $eBay.TabIndex = 1
    $eBay.Text = "eBay"
    $eBay.UseVisualStyleBackColor = $True
    $eBay.add_Click($handler_button1_Click)
     
    $form1.Controls.Add($eBay)
     
    $label1.DataBindings.DefaultDataSourceUpdateMode = 0
     
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 121
    $System_Drawing_Point.Y = 9
    $label1.Location = $System_Drawing_Point
    $label1.Name = "label1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 100
    $label1.Size = $System_Drawing_Size
    $label1.TabIndex = 0
    $label1.Text = "Désinstallation"
    $label1.add_Click($handler_label1_Click)
     
    $form1.Controls.Add($label1)
     
    #endregion Generated Form Code
     
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null
     
    } #End Function
     
    #Call the Function
    GenerateForm
    Merci

  2. #2
    Rédacteur


    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    7 171
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 7 171
    Points : 15 060
    Points
    15 060
    Billets dans le blog
    1
    Par défaut
    Dans un premier temps tu peux utiliser le texte du bouton pour porter l'information, il te faut juste documenter cette possible convention.

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2010
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2010
    Messages : 15
    Points : 14
    Points
    14
    Par défaut
    Bonjour,

    J'ai pas compris votre réponse, que dois-je documenter?

  4. #4
    Rédacteur


    Profil pro
    Inscrit en
    Janvier 2003
    Messages
    7 171
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2003
    Messages : 7 171
    Points : 15 060
    Points
    15 060
    Billets dans le blog
    1
    Par défaut
    Citation Envoyé par maxime1452 Voir le message
    J'ai pas compris votre réponse, que dois-je documenter?
    Oublie.
    Tu peux ajouter du texte au libellé de ton bouton :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    $eBay.Text = "eBay" # Par défaut à installer
     
    $eBay.Text = "eBay (déjà installé)" #Appli présente
    $eBay.Enable= $false
    C'est très simple comme approche, si tu veux plus évolué il te faudras modifier ton IHM.

  5. #5
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2010
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2010
    Messages : 15
    Points : 14
    Points
    14
    Par défaut
    Je laisse tomber pour l'instant, ce n'est plus vraiment d'actualité car mon maitre de stage veux que je passe à autre chose au lieu de perdre du temps avec des optimisations visuelles.

    Merci encore Laurent

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Recherche d'un texte dans la base de registre en VB6
    Par Menerlach dans le forum Téléchargements
    Réponses: 1
    Dernier message: 30/03/2015, 23h06
  2. [MySQL] Recherche d'une valeur dans une base
    Par lodan dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 13/12/2006, 20h01
  3. [9i] Recherche d'une valeur dans une base
    Par alpachico dans le forum Oracle
    Réponses: 1
    Dernier message: 16/06/2006, 09h53
  4. Recherche d'un champ dans une base
    Par vanou dans le forum ASP
    Réponses: 3
    Dernier message: 24/05/2006, 10h31
  5. ASp - recherche d'un champs dans une base.
    Par kmayoyota dans le forum ASP
    Réponses: 5
    Dernier message: 03/12/2004, 15h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo