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.

Share this post


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:

Spoiler

UDFs:
Active Directory (2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version 1.3.5.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version 0.1.0.0) - Download - General Help & Support
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


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"

TestRun()

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"
   Run($sAdminRun)
   EndFunc

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.

Share this post


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.

Share this post


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

Share this post


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

×
×
  • Create New...