reboot?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sam

    #1

    reboot?

    I found reboot script at TechNet and I wonder how to apply in VB.Net?

    Reboot Coding
    ************
    strComputer = "."
    Set objWMIService = GetObject("winm gmts:" _
    & "{impersonation Level=impersona te,(Shutdown)}! \\" & _
    strComputer & "\root\cimv 2")
    Set colOperatingSys tems = objWMIService.E xecQuery _
    ("SELECT * FROM Win32_Operating System")
    For Each objOperatingSys tem in colOperatingSys tems
    objOperatingSys tem.Reboot()
    Next

    Questions?
    ********
    - What namespace that I need? System.Manageme nt?
    - Will this coding work in VB.Net? How? What coding should add?
    - Will it work at Windows Server 2003?

    I need to reboot Windows Server 2003 to clear web cache and SQL cache for
    better memory management.

    Please advise.

    Many thanks.


  • Cor Ligthert

    #2
    Re: reboot?

    sam,

    I saw on Internet this page. I did not test it, my computer is very slow
    shuting down and starting up.

    :-)

    Free software components for C#, VB.NET and other .NET languages.


    Maybe it is something for you.

    Cor


    Comment

    • Peter Proost

      #3
      Re: reboot?

      This should do the trick:

      Public Sub RebootWindows()
      Dim OpSysSet As Object
      Dim OpSys As Object
      OpSysSet =
      GetObject("winm gmts:{impersona tionLevel=imper sonate,(ShutDow n)}").Instances O
      f _("Win32_Operat ingSystem")
      For Each OpSys In OpSysSet
      OpSys.Reboot()
      Next OpSys
      End Sub

      Hth Grtz Peter


      --
      Programming today is a race between software engineers striving to build
      bigger and better idiot-proof programs, and the Universe trying to produce
      bigger and better idiots. So far, the Universe is winning.


      "sam" <samuellai@ajik l.com.my> schreef in bericht
      news:uaexy5UcFH A.1040@TK2MSFTN GP10.phx.gbl...[color=blue]
      > I found reboot script at TechNet and I wonder how to apply in VB.Net?
      >
      > Reboot Coding
      > ************
      > strComputer = "."
      > Set objWMIService = GetObject("winm gmts:" _
      > & "{impersonation Level=impersona te,(Shutdown)}! \\" & _
      > strComputer & "\root\cimv 2")
      > Set colOperatingSys tems = objWMIService.E xecQuery _
      > ("SELECT * FROM Win32_Operating System")
      > For Each objOperatingSys tem in colOperatingSys tems
      > objOperatingSys tem.Reboot()
      > Next
      >
      > Questions?
      > ********
      > - What namespace that I need? System.Manageme nt?
      > - Will this coding work in VB.Net? How? What coding should add?
      > - Will it work at Windows Server 2003?
      >
      > I need to reboot Windows Server 2003 to clear web cache and SQL cache for
      > better memory management.
      >
      > Please advise.
      >
      > Many thanks.
      >
      >[/color]


      Comment

      • Anand[MVP]

        #4
        RE: reboot?

        - What namespace that I need? System.Manageme nt?
        Yes
        - Will this coding work in VB.Net? How? What coding should add?
        I have not tried it , but I dont see why it will not
        - Will it work at Windows Server 2003?
        I dont have as server with me to try, but again it should.

        One thing to note, is that all reboot/log off API need an adminstrator login
        to work.

        --
        Rgds,
        Anand
        VB.NET MVP



        "sam" wrote:
        [color=blue]
        > I found reboot script at TechNet and I wonder how to apply in VB.Net?
        >
        > Reboot Coding
        > ************
        > strComputer = "."
        > Set objWMIService = GetObject("winm gmts:" _
        > & "{impersonation Level=impersona te,(Shutdown)}! \\" & _
        > strComputer & "\root\cimv 2")
        > Set colOperatingSys tems = objWMIService.E xecQuery _
        > ("SELECT * FROM Win32_Operating System")
        > For Each objOperatingSys tem in colOperatingSys tems
        > objOperatingSys tem.Reboot()
        > Next
        >
        > Questions?
        > ********
        > - What namespace that I need? System.Manageme nt?
        > - Will this coding work in VB.Net? How? What coding should add?
        > - Will it work at Windows Server 2003?
        >
        > I need to reboot Windows Server 2003 to clear web cache and SQL cache for
        > better memory management.
        >
        > Please advise.
        >
        > Many thanks.
        >
        >
        >[/color]

        Comment

        Working...