Bonjour à tous,
je cherche à connaitre le moment de dernier reboot d'une machine de mon réseau, via WMI.
Quand je clicke sur le bouton de mon application, absolument rien ne ce passe, il ne m'affiche rien.
Quelqu'un pourrait-il jeter un coup d'oeil à mon code et me dire ce qui ne va pas svp?
Bien à vous.
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 <%@ Page Language="VB" %> <%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <%@ import Namespace="System.Web.Mail" %> <%@ import Namespace="System.IO" %> <%@ import Namespace="System.DirectoryServices" %> <%@ import Namespace="System.Configuration" %> <%@ import Namespace="System.Net" %> <%@ import Namespace="System" %> <%@ import Namespace="System.Net.DNS" %> <%@ import Namespace="System.ComponentModel" %> <%@ import Namespace="System.Management" %> <%@ import Namespace="System.Runtime.InteropServices" %> <%@ import Namespace="System" %> <%@ import Namespace="ActiveDs" %> <%@ import Namespace="System.Management.ConnectionOptions" %> <%@ import Namespace="System.Diagnostics.Process" %> <script runat="server"> ' Insert page code here ' Sub Button1_Click(sender As Object, e As EventArgs) Dim co As ConnectionOptions = New ConnectionOptions() With co .Impersonation = System.Management.ImpersonationLevel.Impersonate '* Use next line for XP .Authentication = System.Management.AuthenticationLevel.Packet '* Use next line for Win prior XP '.Authentication = System.Management.AuthenticationLevel.Connect End With co.Username = "toto" co.Password = "toto" Dim theScope As New ManagementScope("\\192.168.1.2\root\cimv2",co) Dim theQuery As New System.Management.ObjectQuery("SELECT * From Win32_ComputerShutdownEvent") Dim theSearcher As New ManagementObjectSearcher(theScope, theQuery) Dim theCollectionOfResults As ManagementObjectCollection = theSearcher.Get() For Each currentResult As ManagementObject In theCollectionOfResults response.write("Type:"& currentResult(Convert.ToInt32("TIME_CREATED"))) Response.Write("<br>") Response.Write("<br>") Next End Sub </script> <html> <head> </head> <body> <form runat="server"> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button> </p> <!-- Insert content here --> </form> </body> </html>
Partager