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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup message on remote computer 2

Status
Not open for further replies.

MisterC

IS-IT--Management
Apr 19, 2001
501
US
How can I use vbscript to make a message pop up on a remote computer?
 
Take a look at remote scripting.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Code:
Option Explicit
Dim oShell
Dim strCompName
Dim strMsg

Set oShell = CreateObject("WScript.Shell")
strCompName = "ANHEUSER-23AE31"
strMsg = "Hello"

oShell.Run "Net Send " & strCompName & " " & strMsg, 0, True

Set oShell = Nothing

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
WOW that was fast!!
OK, but for that to work the messenger service must be running on the remote computer. Is there any way around that?
 
Use remote scripting as mentioned by PHV.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
That seems to get me closer - I've found:
Code:
strComputer = "RServer"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
    Wscript.Echo "Notepad was started with a process ID of " _
         & intProcessID & "."
Else
    Wscript.Echo "Notepad could not be started due to error " & _
        Error & "."
End If
That will start a process (Notepad.exe). But all I want to do is show a single Message Box.
Any idea where I could find a good remote scripting reference?
Thanks!
 
This is from the WSH documentation which can be downloaded from MS:
WSH 5.6 can run scripts that reside on remote systems. The following scripts demonstrate this capability. These scripts make the assumption that the files are located on a local machine directory called "c:\wsh5.6"; change the local path and the remote machine name as necessary.

After initially running RemoteTest.WSF on the local machine, there may be a small pause as DCOM verifies your identity. After you see the "Done" message, a file named "c:\beenhere.txt" on the remote machine indicates the time that you executed the command (from the remote computer's clock).

// JScript.
RemoteTest.WSF
-------------------------------
<package>
<job>
<script language="JScript">
var oController = new ActiveXObject("WSHController");
var oProcess = oController.CreateScript("c:\\wsh5.6\\beenhere.wsf", "remmachine");
oProcess.Execute();
while (oProcess.Status != 2) WScript.Sleep(100);
WScript.Echo("Done");
</script>
</job>
</package>
-------------------------------
BeenHere.WSF
-------------------------------
<package>
<job>
<script language="JScript">
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fout = fso.CreateTextFile("c:\\beenhere.txt", true);
fout.WriteLine(new Date);
fout.Close();
</script>
</job>
</package>
-------------------------------

' VBScript.
RemoteTest.WSF
-------------------------------
<package>
<job>
<script language="VBScript">
set oController = CreateObject("WSHController")
set oProcess = oController.CreateScript("c:\wsh5.6\beenhere.wsf", "remmachine")
oProcess.Execute
While oProcess.Status <> 2
WScript.Sleep 100
WEnd
WScript.Echo "Done"
</script>
</job>
</package>
-------------------------------

BeenHere.WSF
-------------------------------
<package>
<job>
<script language="VBScript">
set fso = CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile("c:\beenhere.txt", true)
fout.WriteLine Now
fout.Close
</script>
</job>
</package>

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Thank you both for your help, it seems like I'm almost there. One more problem now:
Code:
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript("c:\scripts\mbox.vbs", "RServer")
I'm getting an ActiveX Component can't create object on line 3...... ?
 
RSeerver is the name of the remote machine?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Yes, the mbox.vbs script is on my computer (it is just a test script - Wscript.echo "Testing..."
and the remote machine's name is "RServer"
Also, I have administrative rights.
 
I believe the script needs to reside on the remote cpu.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
No... From Microsoft:

The CreateScript method returns a handle to an instance of a WshRemote object. The path part of the script name does not need to be local — it can refer to a script on a network share. This makes it possible to sit at one computer system, retrieve a script from another computer system, and run it on a third computer system.
 
I stand correected. If you put in 'On Error Resume' then display the Err.Description, what do you get?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Error #429 - ActiveX Component can't create object
 
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript("c:\scripts\mbox.vbs", "RServer")
I believe the problem might be that the Remote Machine is looking in it's own c:\scripts\ directory for the mbox.vbs. Is there a share on the C:\scripts directory? Does the remote machine have a drive mapped to the share? IF so the path would start wit the mapped drive letter rather than C:.
ie. IF remote PC had drive K mapped to C:\scripts on the local machine then the path would be K:\mbox.vbs.
I hope this makes a little sense...[wavey]
sdraper

Sam
 
Hi Sam, Thanks for your help.
Lets see...
The RServer computer does not have a "C:\Scripts" directory. That directory exists only on my machine, which is where the script is running. Also, while my "C:" drive is shared the remote machine does not have a mapped drive pointing to it. I tried using the UNC address of the path, that is: \\HVComp\C:\Scripts\mbox.vbs but that didn't work either.

 
I would try to map a drive on the remote PC to the folder on your local PC and use the mapped drive path. I haven't ever been able to use UNC addresses for this. (I say it this way because there may be a way to do it with UNC that I am unaware of.)
HTH

Sam
 
From Microsoft Windows 2000 Scripting Guide:
Before you can use the WshController object to run scripts on remote computers, you must first ensure that your environment is configured as follows:

- Both the local and target remote computers must be running WSH version 5.6.
- You must add a string-valued entry (REG_SZ) named Remote to the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings and set its value to 1 on all target remote computers. You do not need to add this entry to the registry of the local computer from which you run the controller script.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top