Jump to content

Running a simple msgbox() on a remote computer using PSExec


Recommended Posts

Hi,

I'm trying to run a simple .au3 script [file name: test.au3] containing the following code (i.e. the "only" code it contains):

Msgbox(0,"","TEST")

The file is located on the C:\ directory of the remote computer. I've included both the uncompiled (.au3) and compiled(.exe) versions of the script.

When running the script on my host computer, it (obviously) displays a message box. No problem there. But whenever I run it through PSExec on my remote computer, nothing happens, as in no message box appears. But I do know it is executed because the task manager displays "AutoIt3.exe" (for the uncompiled) or "test.exe" (for the compiled version).

I run the script by entering the following on the command prompt of my host:

cd c:\psexec\

This contains the PSExec.exe.

psexec \\computername -u username -p password cmd.exe

And then the title of the command prompt changes to "\\computername: cmd.exe".

cd c:\

To change the directory to C:\ drive which contains the test.au3 / test.exe.****

test.exe

or

test.au3

The account I'm logging into has administrator privileges and is the sole User account on that computer. (Guest account is not turned on). Both host and remote are running on Windows XP SP2.

Question: What do I need to do to display a messagebox on the remote using PSExec? What steps did I do wrong?

Thanks for the help!

Edit: Elaborated on my problem.

Edit 2: Added some steps that I forgot to include here.****

Edited by Lilbert
Link to comment
Share on other sites

Your script may be locking up before it gets to the msgbox. Check for problems with infinite loops. Also, your script may not be meeting conditions to get to the msgbox, such as an If/Then statement that doesn't do what you are expecting.

If you want more help, you will have to post more code. That's about all I can think of from what little you have told us.

#include <ByteMe.au3>

Link to comment
Share on other sites

Hello sleepydvdr,

This might be embarrassing to say but the msgbox() function is the only line on my "test.au3". You see, I'm still learning how to execute programs on remote computers so I'm doing random simple test. What confuses me is that the script seems to behave differently when running on the host computer and on the remote computer.

Uhmm, maybe I should just change my question: Is it possible to display a message box on a remote computer?

Anyway, I'll trying doing it in a loop.

Link to comment
Share on other sites

Hello sleepydvdr,

This might be embarrassing to say but the msgbox() function is the only line on my "test.au3". You see, I'm still learning how to execute programs on remote computers so I'm doing random simple test. What confuses me is that the script seems to behave differently when running on the host computer and on the remote computer.

Uhmm, maybe I should just change my question: Is it possible to display a message box on a remote computer?

Anyway, I'll trying doing it in a loop.

Hi there,

If your script runs in your computer, it should run in remote computers. I suppose that you compiled your script and you don't have permission issues?

How do you run the script remotely? PSEXEC?

More information would be great in order to help you.

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Hi there,

If your script runs in your computer, it should run in remote computers. I suppose that you compiled your script and you don't have permission issues?

How do you run the script remotely? PSEXEC?

More information would be great in order to help you.

Cheers

Hello,

I've included the details on my first post.

Link to comment
Share on other sites

November's suggestion of PsExec is probably the best way to remotely run an executable. To make your life easier, you should compile your script as an executable. I have worked with PsExec and it gave me a hard time getting it to work, but with persistence, I made it work.

Just make sure Terminal Services are enabled on the computers and you may want to turn off your firewall until you get it working. When you get it working, you will want to create an exception in your firewall rules for it and turn it back on.

#include <ByteMe.au3>

Link to comment
Share on other sites

Hi again,

Simply compile the script and execute it remotely, instead of trying to execute the script(For this option you must have AutoIT installed in the remote computer.

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Hello,

I've included the details on my first post.

You modified your first post to include more details. You should have put those details in a later post because it changes the flow of the conversation. Now it looks like you knew about PsExec this whole time when you didn't.

Also, you are missing the fact that you need to specify the path of the executable. You simply have it as cmd.exe. It should be something like c:\path\cmd.exe.

#include <ByteMe.au3>

Link to comment
Share on other sites

November's suggestion of PsExec is probably the best way to remotely run an executable. To make your life easier, you should compile your script as an executable. I have worked with PsExec and it gave me a hard time getting it to work, but with persistence, I made it work.

Just make sure Terminal Services are enabled on the computers and you may want to turn off your firewall until you get it working. When you get it working, you will want to create an exception in your firewall rules for it and turn it back on.

Hi sleepydvdr,

In case you've missed my update on the first post, I told that I was using PSExec. I also had my script [test.au3] compiled and tried to run it through PSExec. The only change though is the "test.exe" on the task manager, but no message boxes.

Anyway, how do I enable Terminal Services (first time I heart about those)? And I'll try turning off the Windows firewall.

Thanks!

Link to comment
Share on other sites

You modified your first post to include more details. You should have put those details in a later post because it changes the flow of the conversation. Now it looks like you knew about PsExec this whole time when you didn't.

Also, you are missing the fact that you need to specify the path of the executable. You simply have it as cmd.exe. It should be something like c:\path\cmd.exe.

My fault, sorry. But I must say that my original (and unchanged) topic is "Running a simple msgbox() on a remote computer using PSExec" so I was confused when both of you and November were asking if I were using PSExec (when I explicitly included the word "PSExec" on the title.

About totally changing the first post, it's a bad habit of mine. I'll try to refrain doing it in the future.

I'll try to include the full path.

Link to comment
Share on other sites

My fault, sorry. But I must say that my original (and unchanged) topic is "Running a simple msgbox() on a remote computer using PSExec" so I was confused when both of you and November were asking if I were using PSExec (when I explicitly included the word "PSExec" on the title.

About totally changing the first post, it's a bad habit of mine. I'll try to refrain doing it in the future.

I'll try to include the full path.

Sorry, I didn't notice you had PsExec in the title and I didn't remember you mentioning it before.

I think I also ran across another method of executing a program remotely. I'll check my files when I go in to work today. If I can find it, I will let you know what it was.

#include <ByteMe.au3>

Link to comment
Share on other sites

November,

I already did compile my script and tried running it (via PSExec). Again, only thing that happens is the addition of "test.exe" on the task manager of the remote. It actually appeared twice when I double sent this:

test.exe

(Directory was currently set to C:\)

Link to comment
Share on other sites

You should be runnig psexec in interactive mode. The problem is that your text.exe does not have access to the current desktop GUI.

run this:

psexec \\computername -i 0 test.exe

this connects psexec to a running user session. The parameter after -i should be the user session ID. To get this ID, run this on the remote machine:

qwinsta
Link to comment
Share on other sites

Sorry, I didn't notice you had PsExec in the title and I didn't remember you mentioning it before.

I think I also ran across another method of executing a program remotely. I'll check my files when I go in to work today. If I can find it, I will let you know what it was.

Might be because "PsExec" was the last word on the title. And I actually forgot to mention it on my posts. No need to apologize, you're giving out free knowledge anyway, and you're only doing a favor.

Link to comment
Share on other sites

You should be runnig psexec in interactive mode. The problem is that your text.exe does not have access to the current desktop GUI.

run this:

psexec \\computername -i 0 test.exe

this connects psexec to a running user session. The parameter after -i should be the user session ID. To get this ID, run this on the remote machine:

qwinsta

Thanks! That solved it! AND thanks for providing a clear explanation!
Link to comment
Share on other sites

I see you solved your problem. In case anyone wants another solution, the other program I used was called remoteexec. For it, you install a service on the remote machine and an exe will call the remote machine and run the program you specify.

http://www.codeproject.com/KB/system/remoteexec.aspx

#include <ByteMe.au3>

Link to comment
Share on other sites

Thanks! That solved it! AND thanks for providing a clear explanation!

Proving that AutoIT does not have bugs :huh2:

Cheers m8.

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...