Jump to content

a question about the run command


Recommended Posts

I have a script that calls cmd.exe through run(). When I execute the script directly (in front of the computer, click on the script, click run,...etc.) it runs in cmd with my account, c:\"account stuff...". However, when I try to activate the script remotely it runs under "c:\windows\system32". Is there a way that I can change this? Assume that I am logged in as a user with full admin rights to all machines concerned, but that, if possible I would like to avoid having to ask for username and password for every execution of the script.

regards,

the Lab Rat

Link to comment
Share on other sites

FileChangeDir() ?

Jos

Tried that using cd in cmd with no luck. It seems the trouble starts when I try to call the script remotely (through psexec) it runs the script, but the result is access denied because it is running it as c:\Windows\system32 and not c:\"user stuff"

Link to comment
Share on other sites

  • Developers

Tried that using cd in cmd with no luck. It seems the trouble starts when I try to call the script remotely (through psexec) it runs the script, but the result is access denied because it is running it as c:\Windows\system32 and not c:\"user stuff"

A CD in a CMD window would not work unless you start a program in that same CMD session.

The FileChangeDir() will change the workdir of the running script.

Maybe you could explain exactly what you are trying and is failing?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

A CD in a CMD window would not work unless you start a program in that same CMD session.

The FileChangeDir() will change the workdir of the running script.

Maybe you could explain exactly what you are trying and is failing?

Jos

I just tried it, and it correctly changes the directory, but I still get access denied. I think that it is going to a different set of user permissions when I use psexec... I've seen some notes on this in the forum, but there are no concrete solutions that I can find.

As to what I'm doing...

I have a script running on a lab pc that is monitoring an application. The script tells me (on my office pc) when a specific window opens (indicating a specific point in the processing cycle) via psexec, by making a note in a log file and then opening a dialog menu on my office pc and then closes the triggering window and resets itself to monitoring. The problem l'm running into is that when I remotely start the script via psexec from my office pc it doesn't work, and returns an access denied message in cmd; but if start the script from the lab pc it runs just fine.

Link to comment
Share on other sites

  • Developers

I have written quite a few scripts which I ran via PXEXEC on remote pc's and used that to fix issue on those PC's in the background.

What are is your script doing that makes it fail and at what point does it fail?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

perhaps the account the psexec service runs as doesn't have access to that user directory?

Why not specify credentials?

psexec \\computername -u DOMAIN\user -p PASSWORD autoitscript.exe

There are also switches for credential and how psexec is running.. plus if you're doing any sort of window manipulation, you'll want to add the -i switch to run it interactively with the desktop.

Link to comment
Share on other sites

I have written quite a few scripts which I ran via PXEXEC on remote pc's and used that to fix issue on those PC's in the background.

What are is your script doing that makes it fail and at what point does it fail?

Jos

Here is the timeline:

1. execute command via psexec (from office to lab pc)

2. script starts and monitors

3. "trigger" window opens

4. script detects trigger window

5. script sends psexec command to office pc to log event (via a local script). Monitor script closes "trigger window" and rests to monitoring.

---receive psexec "access denied" error here, rest of remote stuff doesn't execute. ---

6. office pc receives psexec command and logs event (via local script)

Link to comment
Share on other sites

  • Developers

(step5)Are you actuallty running another PSEXEC command on the Lab machine to send info back?

Why not just send Console info which is than shown in the commandwindow of the original PSexec command?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

(step5)Are you actuallty running another PSEXEC command on the Lab machine to send info back?

Why not just send Console info which is than shown in the commandwindow of the original PSexec command?

Jos

because I need to have the logging script trigger some automation on the office machine.

Link to comment
Share on other sites

  • Developers

could be I am not fully understanding, but the way I have done it till now is to have a script on my PC running PSEXEC for me which would run a script on the remote PC. The local script would then monitor the returned information in STDOUT of the shelled PSEXEC and depending on what is returned trigger steps on my local PC.

Anyway, you are specifying the UserId&Password on the PSEXEC command which is shelled on the LAB PC?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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