Run as...

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gambetm
Newbie
Posts: 2
Joined: Wed Oct 30, 2002 2:50 pm
Location: NY, NY

Run as...

Post by gambetm » Wed Oct 30, 2002 3:02 pm

In Windows XP and 2000 there is the option to right click on an executable and "run it" in a different domain.
example: I'm logged onto Domain "ABC" but need to run "X" application in Domain "123" as I have rights to certain directories.
I would right click on the executable, select "Run as..." and then enter the Domain/User ID/password to run it.
How can I reproduce this in Macro Scheduler? any ideas? :?:

Ernest

Run as...

Post by Ernest » Fri Nov 01, 2002 10:56 am

Hi,
have you tried to "record" (an MSched option), what you would manualy do ???

The "recorded" script could be something like this (reduced of multiple Wait(s)>)

Code: Select all

MouseMove>screen position of the application
Press RWinKey
Send>Letter assigned to the "run as" -option
Send>Domain/User ID/password
Press Enter
Cause i'm not working with XP/2000 I can't check it, sorry. :)

Ciao Ernest

Ernest

Run as...

Post by Ernest » Fri Nov 01, 2002 11:29 am

Ooops.
replace Press RWinKey with:

Press Shift
Press F10
Release Shift

Shift+F10 = Displays Context Menu for Selected Item


Rgds
Ernest

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Nov 02, 2002 12:18 am

Hi,

The easiest way to do this is to create a shortcut for the application you want to run and set the Run As credentials in the advanced settings. Then just execute this shortcut with Macro Scheduler using the ExecuteFile command:

ExecuteFile>myshortcut.lnk
MJT Net Support
[email protected]

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Run as...

Post by Satch » Wed Apr 06, 2005 2:31 pm

I hope I'm right about this, but on my Windows XP machine, the procedure suggested above would merely activate a Run As [i][b]prompt[/b][/i], which would come up after you execute the shortcut. To achieve the Run As, you would have to add script commands that look for and fill out that subsequent prompt. Perhaps something along the lines of the following would work:

ExecuteFile>myshortcut.lnk
WaitWindowOpen>Run As
Wait>0.05
SetFocus>Run As
Press ALT
Send Character/Text>f
Release ALT
Wait>0.1
Send Character/Text>PCNAME\USERID
Press TAB
Send Character/Text>PASSWORD
Wait>0.1
PushButton>Run As,OK

For info on encrypting your macro to hide the password info in the above script, see the encryption tab in the macro's window and/or search elsewhere in these forums.

--S

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Run as...

Post by Satch » Wed Apr 06, 2005 8:02 pm

Sorry, it turns out that, on my XP machine, the script I just ventured above will NOT work. The "Run As" window, when it is pulled up through a script (as opposed to being pulled up manually by the user launching a shortcut or right-clicking on an appilcation) locks up Macro Scheduler, preventing it from executing any more commands.

If the Administrator / Moderator has any suggestions regarding how to implement his suggested "Run As" procedure in Windows XP, I'd be grateful to know about them. Thanks!

--S

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Run as...

Post by Satch » Wed Apr 06, 2005 8:44 pm

Pending any more elegant a method, I tinkered around and found the following, different method works for me. Below, [FOLDERNAME] is the name of the folder containing the TARGET executable or shortcut you'd like to launch. It might be best to make it a shortcut and to add a couple of unusual letters to the beginning of its name, such as "zz".

ExecuteFile>[path to FOLDERNAME]
WaitWindowOpen>[FOLDERNAME]
Wait>0.05
SetFocus>[FOLDERNAME]
Wait>0.5
Let>SK_DELAY=200
Send Character/Text>[unusual first letters of TARGET name]
Let>SK_DELAY=[0 or WHATEVER IT WAS BEFORE]
Wait>0.3
Press SHIFT
Press F10
Release SHIFT
Wait>0.1
Send Character/Text>u
WaitWindowOpen>Run As
Wait>0.05
SetFocus>Run As
Wait>0.5
Press ALT
Send Character/Text>f
Release ALT
Wait>0.5
Send Character/Text>[COMPUTER NAME]\[USER NAME]
Press TAB
Send Character/Text>[PASSWORD]
Wait>0.5
PushButton>Run As,OK
Wait>1
SetFocus>[FOLDERNAME]
Wait>0.1
Press CTRL
Send Character/Text>w
Release CTRL

Very inelegant, but it works for me. You may need to adjust the durations of the Wait commands and SK_DELAY variable to suit your computer.

--S

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Apr 06, 2005 9:20 pm

Why not just use the runas command. Go to a dos prompt and type runas /?

Run>runas /env /user:Username d:\test.exe
Wait>1
Send>Password
Press Enter
MJT Net Support
[email protected]

Satch
Newbie
Posts: 11
Joined: Wed Mar 30, 2005 3:51 pm

Run as...

Post by Satch » Thu Apr 07, 2005 9:57 pm

Thanks, that sounds great, in general. Sadly, in my case, I'm interested in running the disk defragmenter, and command-line operation of the system's disk defragmenter (dfrg.mcs or its related executables) is not supported under Win XP. (I can't launch the defragmenter using a command-line either manually or via a Macro Scheduler script.)

So, now at least we all have two options---your elegant one for most programs and my heavy-handed one for the few programs that don't support command-line operation.

Thanks again.

--S

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Apr 08, 2005 8:24 am

What's wrong with this then:

Run>runas /env /user:Username "mmc c:\windows\system32\dfrg.msc"
Wait>1
Send>Password
Press Enter
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts