Jerry_Peoples

Using Autoit to create a batch File to run an executable

22 posts in this topic

here is my problem.  I have about 90 users who are not on our network and spread throughout the united states, canada and latin america.

without all the crappy details we need to install a new vpn client that is compatible with out network.  now i can use logmein to remote into everyones computer (along with two coworkers) but aside from being time consuming will take away from other tickets that need addressed.  

I would like to use Autoit to create an executable that will have our administrator password hidden since all our users are standard users and cannot install things on their own.

i have the download of the vpn client but am unsure how to enter our administrator credentials to automate this process.

any help you can give me will be greatly appreciated

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@Jerry_Peoples welcome to the forum. If they have no network connectivity, you would have to embed the password into the script. Something like this:

Local $sPW = "MyAdminPassword!"

Realize, of course, that anyone who wants to spend 5 minutes trying to pull the password from your compiled executable will be able to do so with ease. 

Edit: I missed the part about your users having no access to install apps. So you would embed the password, then do a RunAs and pass those credentials to the script. Look at the example for RunAs in the help file.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I found this on the forum. Use SciTE to compile the code into an exe so it hides account info. This doesn't embed the program you wish to install, just points to it with admin credentials.

 

Hope this helps.

 

$strCmd = "\\server\folder"

$strDomain = "Domain"

$strUser = "Admin"

$strPass = "Password"

runaswait($strUser, $strDomain, $strPass, 0, $strCmd)

 

 

Share this post


Link to post
Share on other sites

it is my understanding (this software was recommended from spiceworks) that once you compile the executable it will run automatically.   most if not all the users are not very computer savvy so i dont think they would try to edit the exe at all

i also should have been more clearer.

i would like to use Autoit to run the exe with our admin password without the user being prompted to enter anything other than just running the exe itself

 

thanks for you help btw

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

So, then your script would look something like this (assuming the setup executable is in the same directory as your script):

RunAsWait("Administrator", "MyDomain", "MyPassword", $RUN_LOGON_NETWORK, @ScriptDir & "\Setup.exe")

Your users would simply have to double click your script and let it run. If you want to further simplify, you could use FileInstall to embed the setup executable into your script file, so they have only one executable to click on.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

JLogan, can you please explain the FileInstall? I have a similar sitituation as Jerry that I need to deploy an MSI ran from a command prompt with token information. Right now I have setup with a batch command to start the setup. What I want is to make it as easy as possible for the enduser to install the software and make the installation as portable as possible.

Perfect scenario would be to eliminate the batch script, one executable, portable, and with domain admin credentials.

Is this possible?

Thanks

Share this post


Link to post
Share on other sites

Yes, @marknlh it is. The help file is very clear about FileInstall, and provides you with an example script to demonstrate its functionality. What are you confused about, exactly?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

I guess I am confused on how I would compile everything I need. Here are the variables:

  1. MSI with external .cab file
  2. Must be ran from cmd using the following
    1. msiexec /i Standalone.msi SERVERURL="https://nsa.nuancehdp.com/basic" ORGANIZATIONTOKEN="your_organization_token" SUPPORTEDLANGUAGES="en-US" SUPPORTEDTOPICS="GeneralMedicine|Cardiology|ClinicalAdministration" USERINTERFACELANGUAGE="en-US"done

       

  3. Need to create a shortcut with a specified name

  4. Compiled into one executable

I wish I had more time and experience with AutoIT but unfortunately I am under a tremendous time constraint.

Any help with a solution would be greatly appreciated!

Share this post


Link to post
Share on other sites

Jlogan, thanks for the response

 

i made a directory called batch

in that directory i placed both the batch file and exe for the vpn client

made the batch file simple for now

RunAsWait("Administrator", "Ardex", "OurNetworkPassword", $RUN_LOGON_NETWORK, @ScriptDir & "\FortiClientOnlineInstaller.exe")

 

double clicked the batch and the window shows for a second then disappears with nothing happening

i should also note i am a beginner with batch files so i am not even sure how to troubleshoot this :/

Share this post


Link to post
Share on other sites

RunAsWait("Administrator", "Ardex", "AdminPassword", $RUN_LOGON_NETWORK, @ScriptDir & "C:\Batch\FortiClientOnlineInstaller.exe")

still no luck.

the folder Batch is on the C:\ drive

i am wondering if the @ScriptDir might have something to do with it?

Share this post


Link to post
Share on other sites

@scriptdir is a macro for the location of your script. So if you have the script in C:\Temp, it will resolve to that. So, your code above, in this case, would resolve to C:\TempC:\Batch\FortiClientOnlineInstaller.exe. See now why it is failing? ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

its like a veil is lifted :)   thanks

Share this post


Link to post
Share on other sites

ok, i should have slowed my roll

 

i changed the part of the code from C:\Batch\FortiClientOnlineInstaller.exe to just \FortiClientOnlineInstaller.exe

put the folder batch back on the desktop and ran it still nothing

looking at the code  @ScriptDir & "C:\Batch\FortiClientOnlineInstaller.exe" 
the ScriptDir is saying, where ever that script is at the exe has to be in the same folder.  which in this case they are in the same folder so it should resolve to it once i made the adjustment

or am i being dense, i have been known to be dense

Share this post


Link to post
Share on other sites

If the install executable is in the same folder as your script then @ScriptDir & "\FortiClientOnlineInstaller.exe" should work.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

should the quotes be around the exe?

Share this post


Link to post
Share on other sites

I guess I am not understanding your question? @ScriptDir is a macro, so you would not surround it with quotes.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@ScriptDir & "\FortiClientOnlineInstaller.exe"

 

this was the code i cut and pasted and adjusted accordingly to what i later posted

Share this post


Link to post
Share on other sites

So are you saying Run(@ScriptDir & "\FortiClientOnlineInstaller.exe") does not launch the executable?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
1 hour ago, JLogan3o13 said:

So are you saying Run(@ScriptDir & "\FortiClientOnlineInstaller.exe") does not launch the executable?

should the ( ) be around the @ScriptDir and the .exe"

the initial code i copied from you did not include that

RunAsWait("Administrator", "MyDomain", "MyPassword", $RUN_LOGON_NETWORK, @ScriptDir & "\Setup.exe")

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