Solved

Visual basic restart remote computer

Posted on 2004-09-03
5
1,086 Views
Last Modified: 2009-10-30
Hello I am looking for a module that will allow me to restart remote computers.  Thanks
0
Comment
Question by:bluedragon99
5 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11976307
Hi

I don't know about remote computers, but you can force a system restart as long as your VB file is on their computer:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;168796

A problem in NT and 2000 and XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;176695#appliesto

Regards,
Zyloch
0
 
LVL 5

Expert Comment

by:rsriprac
ID: 11977134
Here is a VB script to reboot remote computer:

http://www.freevbcode.com/ShowCode.Asp?ID=4889

-Ram
0
 
LVL 4

Expert Comment

by:Sicos
ID: 11977543
Just use tsshutdn ... it included in Windows 2000 and up... you can use it to restart remote servers..
As long you've got right for it on that server.

You also can call the program from VB or something like that.. just use WinEXec command for it.

Shut down a server in a controlled manner.

TSSHUTDN [wait_time] [/SERVER:servername] [/REBOOT] [/POWERDOWN]
         [/DELAY:logoffdelay] [/V]

  wait_time           Seconds to wait after user notification before
                      terminating all user sessions (default is 60).
  /SERVER:servername  The server to shut down (default is current).
  /REBOOT             Reboot the server after user sessions are terminated.
  /POWERDOWN          The server will prepare for powering off.
  /DELAY:logoffdelay  Seconds to wait after logging off all connected
                      sessions (default is 30).
  /V                  Display information about actions being performed.


Greetings Sicos..
0
 
LVL 3

Accepted Solution

by:
Validor earned 500 total points
ID: 11977860
I've written a VB module to do this for you.  This should reboot any remote (or the local) machine running an NT-based operating system if you have sufficient rights.  Example:


Private Sub Command1_Click()
    RestartRemoteComputer "myserver", roReboot
End Sub

'---------------------------

Public Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias "InitiateSystemShutdownA" (ByVal lpMachineName As String, ByVal lpMessage As String, ByVal dwTimeout As Long, ByVal bForceAppsClosed As Long, ByVal bRebootAfterShutdown As Long) As Long

Public Const roShutDown = 0
Public Const roReboot = 1

Public Sub RestartRemoteComputer(aComputerName As String, aRebootOption As Integer)
    InitiateSystemShutdown _
        aComputerName + Chr$(0), _
        "Shutting down...", _
        10, _
        1, _
        aRebootOption
End Sub
0
 
LVL 1

Author Comment

by:bluedragon99
ID: 11978089
Very nice clean working code that matches the description of the question.  Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question