Bonsoir à toutes et à tous,

Je viens d'écrire un script (avec l'aide des discussion du forum) permettant de configurer les PC de mon entreprise (création raccourci, config profil exchange,...) :

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
MsgBox "Script d'aide à la configuration des PC"
'########################################
MsgBox "Cliques sur OK pour lancer Mon appli"
Dim IE
Set IE = Wscript.CreateObject("InternetExplorer.Application")
IE.Visible = True 
IE.navigate "http://Mon appli.html"
Dim Shell, DesktopPath, URL
	Set Shell = CreateObject("WScript.Shell")	
	DesktopPath = Shell.SpecialFolders("Desktop")
	Set URL = Shell.CreateShortcut(DesktopPath & "\Mon appli.URL")
	URL.TargetPath = "http://Mon appli.html"
	URL.Save
'########################################
Wscript.Sleep 2000 ' durée en ms .. 2000 => 2 s
'########################################
MsgBox "Cliques sur OK pour Mon appli1"
IE.Visible = True
IE.navigate "http://Mon appli1.htm"
	DesktopPath = Shell.SpecialFolders("Desktop")
	Set URL = Shell.CreateShortcut(DesktopPath & "\http://Mon appli1.URL")
	URL.TargetPath = "http://Mon appli1.htm"
	URL.Save
'########################################
Wscript.Sleep 2000 ' durée en ms .. 2000 => 2 s
'########################################
MsgBox "Cliques sur OK pour lancer Mon appli2"
IE.Visible = True 
IE.navigate "http://Mon appli2.html"
	DesktopPath = Shell.SpecialFolders("Desktop")
	Set URL = Shell.CreateShortcut(DesktopPath & "\Mon appli2.URL")
	URL.TargetPath = "Mon appli2.html"
	URL.Save
'########################################
Wscript.Sleep 2000 ' durée en ms .. 2000 => 2 s
'########################################
MsgBox "Cliques sur OK pour créer la connexion au lecteur réseau"
Dim oNet 
Set oNet = CreateObject("Wscript.Network") 
oNet.MapNetworkDrive "Y:", "\\xxxxx\yyyyy\zzzzz"
'Ici je souhaite créer un raccourci bureau
'########################################
Wscript.Sleep 2000 ' durée en ms .. 2000 => 2 s
'########################################
'Script de génération du profil exchange xxxxx
MsgBox "Cliques sur OK pour créer la BAL xxxxx"
 
const ExchangeServer = "xxxxx"
dim user 
'recuperation de l'utilisateur connecté 
 
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
chemin =  WshSysEnv("USERPROFILE")
'user = inputbox("saisir le nom d'utilisateur","utilisateur xxxxx")
user = "xxxxx"
'ouverture du fichier à modifier 
 
set objFso =  WScript.CreateObject("Scripting.FileSystemObject")
 
'verifie la presence du fichiers 
 
If (objFSO.FileExists(".\Acc.reg")) then
 
'Creation du fichier … utiliser
 
            if objFSO.FileExists(chemin & "\acc" & user & ".reg") then 
                   objFSO.deleteFile(chemin & "\acc" & user & ".reg")
            end if                  
 
      set RegFile = objFSO.CreateTextFile (chemin & "\acc" & user & ".reg",True,-1)
 
  'modification du texte
   Set fic = objFSO.OpenTextFile(".\Acc.reg",1,True, -1)
 
   ContenuFic = fic.readall
	 ContenuFic=split(ContenuFic,vbcrlf)	
   Fic.close
	 set fic = nothing
		replstr1 = "USERBAL"				
    replstr2 = "EXCHSERVER"       
            for each ligne in ContenuFic 
 
		            if instr(ucase(ligne),replstr1)>0 then
		                ligne = replace (ligne,replstr1,user,1,-1,1) 
                end If
 
                 if instr(ucase(ligne),replstr2)>0 then                  
                 	            ligne = replace (ligne,replstr2,ExchangeServer,1,-1,1)
                 end if 
               RegFile.writeline ligne
            next        
 
else 
 
	msgbox "Attention ! le fichier ACC.reg n'est pas present"
	wscript.quit 
 
end if 
 
RegFile.close
'inscription des informations au registre
 
CmdLine = "reg import """ &  chemin & "\acc" & user & ".reg"""
 
objexec = WshShell.Run("cmd /C" & CmdLine, 1, TRUE)
 
'suppression du fichier 
 
objFSO.deleteFile(chemin & "\acc" & user & ".reg")
 
 
set objFSO 	= nothing
set WshShell 	= nothing
 
 
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("outlook.exe" , 1, true)
'Ici je souhaite renseigner (voir shoot écran en PJ) automatiquement
'########################################
Wscript.Sleep 2000 ' durée en ms .. 2000 => 2 s
'########################################
MsgBox "Configuration terminée !"
Tout fonctionne parfaitement, mais je souhaite encore améliorer ce script :

- Création d'un raccourci bureau après la connexion au lecteur réseau
- Renseigner (voir shoot écran en PJ) automatiquement les différents champs
- Peut-on ouvrir les 3 fenêtres IE sans les fermer les unes après les autres ?

J'ai beau chercher, je reste bloqué sur ces 3 souhaits !

D'avance merci pour les réponses qui me parviendront.

Bien cordialement.

Ananar