Results 1 to 5 of 5

Thread: How to call Win32Shutdown method in a proper way

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    How to call Win32Shutdown method in a proper way

    Does anyone know how to call Win32Shutdown method of Win32_OperatingSystem class.

    Here is what I have got so far:

    VB Code:
    1. Dim OSClass As New ManagementClass("Win32_OperatingSystem")
    2.  
    3.         ' Get an input parameters object for this method
    4.         Dim inParams As ManagementBaseObject = processClass.GetMethodParameters("Win32Shutdown")
    5.  
    6.         ' Fill in input parameter values
    7.         inParams("Flags") = 2
    8.        
    9.         ' Execute the method
    10.         Dim outParams As ManagementBaseObject = processClass.InvokeMethod("Win32Shutdown", inParams, Nothing)

    I got an error 'invalid method Parameter(s)' when it reached the last line InvokeMethod. What I want to do is just to shutdown the machine using VB.NET.

  2. #2

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    anyone????

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    if you want to use Management object , here's a link ( in C# but easy to understand )
    ShutDown Windows with System.Management
    although i prefer to use ExitWindowsEx , an example in vb6 ( but easy to translate to .net can be found here...ExitWindowsEx to shutdown windows
    if i get chance sometime i'll throw an example together ( but not sure when cuz of feeding duties etc... )
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    Thx a lot, thats solved the problem.

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    no problem
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width