Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Popup message on remote computerHelpful Member!(2) 

MisterC (IS/IT--Management) (OP)
19 May 04 14:58
How can I use vbscript to make a message pop up on a remote computer?
Helpful Member!  PHV (MIS)
19 May 04 15:04
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

Helpful Member!  EBGreen (Programmer)
19 May 04 15:05

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

"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

MisterC (IS/IT--Management) (OP)
19 May 04 15:12
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?
EBGreen (Programmer)
19 May 04 15:15
Use remote scripting as mentioned by PHV.

"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

MisterC (IS/IT--Management) (OP)
19 May 04 15:26
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!
PHV (MIS)
19 May 04 15:30
You may take a look here:
http://msdn.microsoft.com/library/en-us/rmscpt/Html/rmscpt.asp

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244

EBGreen (Programmer)
19 May 04 15:32
This is from the WSH documentation which can be downloaded from MS:

Quote:


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>

"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

MisterC (IS/IT--Management) (OP)
19 May 04 15:51
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...... ?
EBGreen (Programmer)
19 May 04 15:53
RSeerver is the name of the remote machine?

"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

MisterC (IS/IT--Management) (OP)
19 May 04 15:57
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.
EBGreen (Programmer)
19 May 04 16:00
I believe the script needs to reside on the remote cpu.

"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

MisterC (IS/IT--Management) (OP)
19 May 04 16:04
No... From Microsoft:

Quote:


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.
EBGreen (Programmer)
19 May 04 16:11
I stand correected. If you put in 'On Error Resume' then display the Err.Description, what do you get?

"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

MisterC (IS/IT--Management) (OP)
19 May 04 16:18
Error #429 - ActiveX Component can't create object
sdraper (Programmer)
25 May 04 15:49
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...
sdraper

Sam

MisterC (IS/IT--Management) (OP)
25 May 04 16:02
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.

sdraper (Programmer)
25 May 04 16:08
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

EBGreen (Programmer)
25 May 04 16:30
From Microsoft Windows 2000 Scripting Guide:

Quote:


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.

"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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close