Bonjour,
Tout d'abord, je n'y connais rien en VBS. Les scripts présentés ne sont pas de moi
J'ai un script VBS qui m'exécute certaines tâches.
Le problème s'est qu'une fois les tâches finies, le script ne me rend pas la main.
NOTE : j'exécute ces scripts à l'aide d'un script batch.
Comment faire pour ravoir la main ?
script BATCH :
script VBS :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 psExec \\IP -u USER -p MOTDEPASSE C:\Script_migration\migration_users\Migration_home.vbs /Old_User:%1 /New_user:%2 C:\Script_migration\migration_users\Migration_Notes.vbs %1 %2 pause
2eme script VBS :
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 ' ############## Script de migration des homes utilisateur AD ############## ' #### Declaration des variables ###### N_User = (WScript.Arguments.Named.Item("New_User")) O_User = (WScript.Arguments.Named.Item("Old_User")) Connect = "LDAP://cn=" & N_User & ",OU=MU,OU=WXP,OU=Platform,OU=AKF,OU=Plants,dc=akf,dc=toto,dc=int" Set objUser = GetObject (Connect) strComputer = "akfsrv066" Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") ' #### Migration du profile dans AD ###### objUser.Put "homeDirectory", "\\AKFSRV066\" & N_User & "$" objUser.Put "homeDrive", "P:" objUser.SetInfo ' #### Suppression du share home de l'utilisateur ###### Requete = "Select * from Win32_Share Where Name = '" & O_User & "$'" Set colShares = objWMIService.ExecQuery (Requete) For Each objShare in colShares objShare.Delete Next ' #### Migration du repertoire home ###### Set objFSO = CreateObject("Scripting.FileSystemObject") OLDFOLDER= "\\akfsrv066\persos$\" & O_User NEWFOLDER= "\\akfsrv066\persos$\" & N_User 'WScript.Echo OLDFOLDER 'WScript.Echo NEwFOLDER objFSO.MoveFolder OLDFOLDER , NEWFOLDER ' #### creation du share home de l'utilisateur ###### Const FILE_SHARE = 0 Set objNewShare = objWMIService.Get("Win32_Share") N_USER2= N_User & "$" 'WScript.Echo N_USER2 errReturn = objNewShare.Create ( "d:\persos\" & N_User, N_USER2, FILE_SHARE, , "Repertoire personnel de " & N_User)
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 set oShell = WScript.CreateObject("WScript.Shell") Set wshArguments = WScript.Arguments OLDUSERNAME= wshArguments(0) NEWUSERNAME= wshArguments(1) ' ####### Renommage du repertoire Notes ############ Set objFSO = CreateObject("Scripting.FileSystemObject") OLDFOLDER="Q:\" & OLDUSERNAME NEWFOLDER="Q:\" & NEWUSERNAME objFSO.MoveFolder OLDFOLDER , NEWFOLDER ' ####### edition du fichier notes.ini ############# FILE="Q:\" + NEWUSERNAME + "\notes.ini" oShell.Run "notepad" WScript.Sleep 100 oShell.AppActivate "Notepad" oShell.SendKeys "%fo" oShell.SendKeys FILE & "{ENTER}" oShell.SendKeys "%er\" & OLDUSERNAME & "\{TAB}\"& NEWUSERNAME & "\{TAB}{TAB}{TAB}{TAB}{ENTER}" oShell.SendKeys "{TAB}{ENTER}" oShell.SendKeys "%fa" 'Send the filename to notepad oShell.SendKeys "Q:\"& NEWUSERNAME & "\notes.ini{ENTER}" oShell.SendKeys "{TAB}{ENTER}" oShell.SendKeys "%fx" ' ####### renomage du fichier ID ################### 'OLDID="Q:\" & NEWUSERNAME & "\" & OLDUSERNAME & ".ID" 'NEWID="Q:\" & NEWUSERNAME & "\" & NEWUSERNAME & ".ID" 'objFSO.MoveFile OLDID , NEWID
Partager