Bonjour,

Voilà j'aimerai vous soumettre un problème que je ne m'explique pas. Je suis en trin de développer une application en vb.net dans laquelle je lance un script vbs. Mon problème est le suivant :

Lorsque j'exécute mon script vbs en ligne de commande, il se lance sans aucune erreur. Par contre lorsque je fais exécuter exactement le même script il me ressort une erreur de permission.

Je vais vous mettre le code de mon script ainsi que le bout de code vb ou je fais appel à ce script. L'erreur se produit ligne 43,2 dans l'appel à ce script

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
'Initialisation des variables
 
Const ForReading = 1
Const ForWriting = 2
Dim oFso, f, Fsw, w
Dim chaine
 
Set Fsw = CreateObject("Scripting.FileSystemObject")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set f = oFso.OpenTextFile("C:\Documents and Settings\Michael BRUNIAS\Bureau\Liste.txt", ForReading)
While Not f.AtEndOfStream
	ligne = f.readLine
	chaine = split(ligne," ")
	strComputer = chaine(0)
	strUser = chaine(1)
	strPassWord = chaine(2)
 
	os = ""
 
'On récupére les données désirées
	Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
	Set objWMIService = objSWbemLocator.ConnectServer(strComputer,_
		"root\CIMV2",_
		strUser,_
		strPassword,_
		"MS_409",_
		"ntlmdomain:" + strDomain)
'On récupere l'OS du PC
	Set colItems = objWMIService.ExecQuery(_
		"Select * FROM Win32_OperatingSystem",,48)
	For Each objItem in colItems
		os = objItem.Name
	Next
'On récupere le constructeur du PC
	Set colItems = objWMIService.ExecQuery(_
			"SELECT * FROM Win32_BIOS",,48)
		For Each objItems in colItems
			manufac = objItems.Manufacturer
		Next
 
'on créer un fichier avec les informations souhaités
	information = manufac & ":" & os
	Set w = Fsw.OpenTextFile("C:\Documents and Settings\Michael BRUNIAS\Bureau\info.txt",ForWriting,true)
	w.write(information)
	w.close()
Wend
f.close()
Appel au script :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
Dim Processus As New ProcessStartInfo("C:\Documents and Settings\Michael BRUNIAS\Bureau\wmi.vbs")
        Process.Start(Processus)
        Dim sr As New StreamReader("C:\Documents and Settings\Michael BRUNIAS\Bureau\info.txt")
        Dim osmanu As String = sr.ReadLine()
        Dim enclitter As String()
        enclitter = osmanu.Split(carTrim)
        TextBox9.Text = enclitter(0)
        TextBox10.Text = enclitter(1)
        Kill("C:\Documents and Settings\Michael BRUNIAS\Bureau\info.txt")