Jump to content

Running Remote commands with impersonation


Recommended Posts

Hello guys.

I'm a bit of a newbie but still remember the old Dos Scripting Days and batch files.

I have a rather curious problem. i have some third party printing software that occasionally crashes and since we work 24hrs , we are often get calls at 1am to simply close the error dialog and restart the program. While we await a permanent fix for the crashing program, i'd like to use Autoit to

a) allow a user without Admin rights on the server to run a batch file that will

1. Clear all print jobs on que

2. Click "Ok" on the error dialog popup

3. Restart the offending software :)

Thats it.

I've been scouring the forum , help files etc and have an idea what to do. What stumps me is how to run the batch file i place on the server (that will do the above 3 steps) as though its running on the server (ie Impersonate the admin and local logon)

Any ideas guys (i'm looking at pstools but i'd rather use AutoIt)

Thanks!

Link to comment
Share on other sites

Thanks Lar,

Actually i'm using a combination.(or trying to!) I've installed autoit on the server and scripted the neccesary steps to restart the app after purging stuck print jobs. This works on the server.

On the user's machine, i use a batch file with psexec to run the script remotely. The problem i'm having now is that whenever i build the exe on the server (from autoit) it doesnt run, i get the error "Unable to Open Script file" :)

Link to comment
Share on other sites

I managed to solve my problem using Windows scheduler. First used Autoit to check (Winexists) if the error dialog is there and only then does it kill the old process and start a new one. this is the 3rd day and so far so good.

Now,

This was not my original intention. I intended to have a batch file on the users desktop and when the error occured they would be able to run it and kill the process etc. I however couldnt get this to work. EVEN using Psexec i found that the Autoit script ran on the server but restarting the application did not restart it in the normal way!. there would be an instance in Task Manager but that instance had no window! (yes i used the @Maximize Option in Run command). Also it causes user requests to crash continously.

what is interesting is that on the server, the same script runs without a problem and restarts my app with a visible window and works perfectly.

I tried running PSEXEC with admin username and password and with the -i option to allow interactivity but none of this made a difference.

Has anybody come across such a problem and how did you solve it?

Link to comment
Share on other sites

well i have an idea that might help...

runasset('','','')

check out this command in the autoit help file then use the run('') command with it.

this could let users who arent admin do stuff... you could have this run software that communicates with the server and allow everybody to use the software with admin.

but as for the process running in an invisible window.... if when you run the script on the server it comes up as a different user in task manager as when you run the script from a user's desktop, you can put runasset() in the script you run off of your desktop to run it on the server as the correct user.

Edited by Qball
Link to comment
Share on other sites

I managed to solve my problem using Windows scheduler. First used Autoit to check (Winexists) if the error dialog is there and only then does it kill the old process and start a new one. this is the 3rd day and so far so good.

Now,

This was not my original intention. I intended to have a batch file on the users desktop and when the error occured they would be able to run it and kill the process etc. I however couldnt get this to work. EVEN using Psexec i found that the Autoit script ran on the server but restarting the application did not restart it in the normal way!. there would be an instance in Task Manager but that instance had no window! (yes i used the @Maximize Option in Run command). Also it causes user requests to crash continously.

what is interesting is that on the server, the same script runs without a problem and restarts my app with a visible window and works perfectly.

I tried running PSEXEC with admin username and password and with the -i option to allow interactivity but none of this made a difference.

Has anybody come across such a problem and how did you solve it?

When the user launches the script, are you expecting interactivity on the user's desktop, or on the server? There are some pretty clear guidelines in this SysInternals forum's thread http://forum.sysinternals.com/forum_posts....;PN=1&TPN=2
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...