Solved

Visual basic restart remote computer

Posted on 2004-09-03
5
1,094 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 81
AutoIncrement column based of FK 11 64
ejb message driven bean mdb creation steps 2 36
Assignment from incompatible pointer type? 2 40
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…

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