By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

reboot?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
- 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.