473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 2207
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ben Allen | last post by:
Is there a way (through a variable) to show the date of the last server reboot i.e. when PHP last started running? As I am trying to show the server uptime, which of course only works from the last...
6
by: Stephane Dalpe | last post by:
Hi all, I just want to know why when I'm installing jdk sometimes ask me to reboot and sometimes he don't. As part of our installation, we launch the jdk installation if it's not already...
1
by: ------------------ eric -------------------- | last post by:
Any idea how to reboot a givin machine useing the ststem.management namespace? thanks eric.
0
by: ThunderMusic | last post by:
Hi, I'm trying to install VS.NET 2003 and it keeps asking me to reboot the computer for installing the first step. After rebooting, I try to install the first step, then it tells me again an...
10
by: JL | last post by:
To All, I have a SQL2KSP3a database(<1GB) running on a 4x3GB physical CPU with 4GB of ram. It is Windows Server 2003 with hyper-threading turn on. There are ~420 .Net users/cxns (fat client, no...
1
by: Aaron | last post by:
Not sure if this is the best spot to post this question, but I am not going to pay money to ask an installation question.... Anyways I am trying to install C# standard 2003 and it analyzes the...
3
by: iamsiju | last post by:
Hi, I am facing a problem with the Perl Telnet Object. My Telnet Object hangs just after issueing reboot command on the remote host. Please help me who faced this problem !!! Thanks in...
2
by: =?Utf-8?B?VHJhY2tz?= | last post by:
When I run my setup of a vb.net app made in VS2005 and setup made with the setup wizard and then modified in the ide, The .net 2 setup runs and installs and then asks to reboot. If you answer ok...
3
by: cj | last post by:
My program shuts itself down and reboots the pc it's running on at 2:00am twice a week and has been doing so without fail for over a year. But twice in the past month it's been found running in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.