469,909 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

reboot?

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

Reboot Coding
************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next

Questions?
********
- What namespace that I need? System.Management?
- 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.
Nov 21 '05 #1
3 2069
sam,

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

:-)

http://www.mentalis.org/soft/class.qpx?id=7

Maybe it is something for you.

Cor
Nov 21 '05 #2
This should do the trick:

Public Sub RebootWindows()
Dim OpSysSet As Object
Dim OpSys As Object
OpSysSet =
GetObject("winmgmts:{impersonationLevel=impersonat e,(ShutDown)}").InstancesO
f _("Win32_OperatingSystem")
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" <sa*******@ajikl.com.my> schreef in bericht
news:ua**************@TK2MSFTNGP10.phx.gbl...
I found reboot script at TechNet and I wonder how to apply in VB.Net?

Reboot Coding
************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next

Questions?
********
- What namespace that I need? System.Management?
- 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.

Nov 21 '05 #3
- What namespace that I need? System.Management?
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
http://www.dotnetindia.com
"sam" wrote:
I found reboot script at TechNet and I wonder how to apply in VB.Net?

Reboot Coding
************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\ \" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next

Questions?
********
- What namespace that I need? System.Management?
- 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.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Ben Allen | last post: by
1 post views Thread by ------------------ eric -------------------- | last post: by
2 posts views Thread by =?Utf-8?B?VHJhY2tz?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.