Jump to content

AutoIT3 Script: remote execution with psexec.exe


Recommended Posts

Hi.

I'm trying to run autoit script on remote machine (with psexec from SysInternals\PCTools). Here is how I do it:

1. On local machine, I run the following code (local.bat):

psexec.exe \\remotecomp -u remoteuser -p password -i c:\windows\remote.bat

2. The content of remote.bat located on remote machine:

"C:\Program Files\AutoIt3\autoit3.exe" C:\work\remotetest.au3

3. The content of remotetest.au3:

run ('cmd /c "compmgmt.msc"', @SystemDir, @SW_HIDE)

4. When I run my local.bat, I get the following error on my remote machine:

---------------------------

Microsoft Visual C++ Runtime Library

---------------------------

Runtime Error!

Program:

This application has requested the Runtime to terminate it in an unusual way.

Please contact the application's support team for more information.

---------------------------

OK

---------------------------

5. If my remotetest.au3 contained only this code, it would work fine:

MsgBox(0, "Test", "Hello world!")

It means, something wrong with

run ('cmd /c "compmgmt.msc"', @SystemDir, @SW_HIDE)

Any suggestions? Thanks in advance,

Link to comment
Share on other sites

2. The content of remote.bat located on remote machine:

"C:\Program Files\AutoIt3\autoit3.exe" C:\work\remotetest.au3
I maybe wrong here but I you need to compile the au3 file into an exe file. From there you should not have any problems running it as long as your code has no errors in it.

RUN . . . Slide . . . TAG . . . Your out . . . PAINTBALL !!!

Link to comment
Share on other sites

I maybe wrong here but I you need to compile the au3 file into an exe file. From there you should not have any problems running it as long as your code has no errors in it.

Thanks for advice but it didn't help. I made it executable but I'm getting the same error...

Link to comment
Share on other sites

What happens if you replace cmd with @Comspec?

you could also try @WindowsDir & "\system32\mmc.exe"

Edited by spudw2k
Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Link to comment
Share on other sites

What happens if you replace cmd with @Comspec?

you could also try @WindowsDir & "\system32\mmc.exe"

Thanks for advice. I tried the followin variants:

run (@COMSPEC & " /c" & 'compmgmt.msc', @SystemDir, @SW_HIDE)

and

run (@COMSPEC & " /c" &@WindowsDir & '\system32\mmc.exe', "", @SW_HIDE)

Same result. Did it work in your environment? I mean, remote execution, not local one.

Link to comment
Share on other sites

I would read the help files about run, @ComSpec, and look at the examples they give. I was able to get it to work locally.

Yes, I have been reading it. No problem to work locally. The main point is specified in the topic: remote execution. Did it work in your environment? Thanks.

Link to comment
Share on other sites

It should. I've never had such a problem.

run(@COMSPEC & " /c " & @WindowsDir & "\system32\mmc.exe compmgnt.msc", "", @SW_HIDE)
Edited by spudw2k
Spoiler

Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder
Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array
Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc
Cool Stuff: AutoItObject UDF â—Š Extract Icon From Proc â—Š GuiCtrlFontRotate â—Š Hex Edit Funcs â—Š Run binary â—Š Service_UDF

 

Link to comment
Share on other sites

It should. I've never had such a problem.

run(@COMSPEC & " /c " & @WindowsDir & "\system32\mmc.exe compmgnt.msc", "", @SW_HIDE)
Thanks for feedback. It works locally, but not remotely. Actially, it is clear now the reason is out of AutoIT scope. If I run this code on local machine:

psexec.exe \\remotecomp -u remoteuser -p password -i c:\windows\remote.bat

and remote.bat contain this string:

mmc.exe

then I have Runtime Error specified in the beginning of this topic. The same error is when I use beyondexecv2.exe instead of psexec.exe.

That's it :)

Link to comment
Share on other sites

Thanks for feedback. It works locally, but not remotely. Actially, it is clear now the reason is out of AutoIT scope. If I run this code on local machine:

psexec.exe \\remotecomp -u remoteuser -p password -i c:\windows\remote.bat

and remote.bat contain this string:

mmc.exe

then I have Runtime Error specified in the beginning of this topic. The same error is when I use beyondexecv2.exe instead of psexec.exe.

That's it :)

The problem disappeared when I got the last version of PsExec. Earlier, I used to work with older one (1.3).

PsExec v1.82

Thanks to all !

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...