Solved

Visual basic restart remote computer

Posted on 2004-09-03
5
1,101 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

726 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