Jump to content

Recommended Posts

Hi i have been running into a few issue with a simple "RunAs" prefix.

In the help it lists:

RunAs ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag]]] )

if i make those into variables like:

Global $Domain = "Domain.net" OR "Domain" OR "Domain\"
Global $UserName = "ITtest" 
Global $Password = "Password"

Do i include the ".net" at the end for my domain? Or do i use a "domain\" Ect.

I'm new to the forms and not sure the best way to go about posting this.

Link to post
Share on other sites
  • Moderators

Have you tried all three? Are you getting errors? Have you then looked at the running process in Task Manager to see what user account it is running under? Which works for you?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

As an example run

MsgBox(0, "", @LogonDomain)

to get the name of the domain you are currently logged in.

My UDFs and Tutorials:


Active Directory (NEW 2021-06-05 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version - Download - General Help & Support - Wiki

ADO - Wiki, WebDriver - Wiki


Link to post
Share on other sites

So the "@logonDomain" is what i was looking for there.

but now i'm still having a issue with the "RunAs"


Global $sDomain = @LogonDomain
Global $sUserName = "ITtest"
Global $sPassword = "Password"
Global $sAdminRun = RunAs($sUserName, $sDomain, $sPassword, $RUN_LOGON_NETWORK, $ProgramName)

Func TestRun()
   local $ProgramName = "Z:\Installer Files\TreeSize\TreeSizeProfessional\TreeSize-x64-Full.exe"

I'm trying to run a program as a different domain user than the one that is currently logged on.

I was trying to use the $ProgramName as a variable for each function but i'm getting a "Not Declared"?

Again i'm pretty new to the whole Autoit Scene but im learning fast.

Link to post
Share on other sites

First you call the function before you declared your variables.  They are unknown at the moment of your call. Second you the run statement is wrongly formatted (read help file carefully).  Third the runas uses a variable local to a function, thus inaccessible. 

Global $sDomain = @LogonDomain
Global $sUserName = "ITtest"
Global $sPassword = "Password"
Global $ProgramName = "Z:\Installer Files\TreeSize\TreeSizeProfessional\TreeSize-x64-Full.exe"

Global $sAdminRun = RunAs($sUserName, $sDomain, $sPassword, $RUN_LOGON_NETWORK, $ProgramName)
MsgBox (0,"","This is a PID " & $sAdminRun)

There is no need in your code to create a func.

Link to post
Share on other sites

Thanks Nine and Bert,

I guess my plan was to have a function for each Program install.

I'm doing a lot of upgrades for our AutoCad programs and instead of touching 60+ Workstations i was trying to make a program/Script to run those installers as a Domain Account with Administration access.

I understand what happened with that copy of the script, i realized i was calling before my variables and moved it.

I also looked at your project bert, do you know if there is any way to inject custom fields like "Company Name" "Product Keys" etc. into the batch install for apps that don't have native batch installing? In my case Solid Edge Viewer 2019.

Thanks again guys

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...