ToastyScripter Posted April 24, 2019 Share Posted April 24, 2019 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 comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 24, 2019 Moderators Share Posted April 24, 2019 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 comment Share on other sites More sharing options...
water Posted April 24, 2019 Share Posted April 24, 2019 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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
ToastyScripter Posted April 24, 2019 Author Share Posted April 24, 2019 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. Link to comment Share on other sites More sharing options...
Nine Posted April 24, 2019 Share Posted April 24, 2019 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Bert Posted April 24, 2019 Share Posted April 24, 2019 Toasty - look at my signature for the Vollatran project. It has much of what you are looking for. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
ToastyScripter Posted April 24, 2019 Author Share Posted April 24, 2019 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 comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now