Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening multiple DOS boxes when running script

Status
Not open for further replies.

redcare

Technical User
May 20, 2001
32
GB
Hi

I'm new to vb scripting and what I'm trying to do is reboot a remote machine with a script and at the same time the server is reloading the script will bring up a running dos ping command. Unfortunatley whenever i try running this script it brings up multiple dos boxes and freezes my pc.
Here is the code.
Iam running this script within a hta file if thats any help.
==============================================
Sub GetRestart

strcomputer = ""
strComputer = servername.value
if strcomputer = "" Then
Msgbox "Please enter a server name"
exit sub
End if

On error resume next

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

set wshShell= createobject("wscript.shell")
wshShell.run "%comspec% /k ping -t " & strcomputer ,1,true


End Sub
=====================================
 
I don't see where the code you have posted would cause multiple window pop-ups. Is there more to your code than this? A loop somewhere?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
No thats the entire code.
But the weird thing is when I moved the file to another directory on my pc it worked ok.
If I put it back in the original directory where I created it same old problem.
So who knows.
Anyway thanks for the reply.
 
What is the name of your script ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top