Jump to content
sadlerd

Script Help

Recommended Posts

sadlerd

Running Win 7 I'm trying to create a very basic script that will Run on a "standard" non elevated account and running into issues with the script. 

Basically, mapping the Install Drive with Admin account, copyingthe  "reg and bat files" into an MIS Folder, RunAsSet with Local Admin Info

then removing the folder after and restarting the PC.  What am I doing wrong with the Win 7 ? 

 

DriveMapAdd( "X:", "\\adp2\ad_installs" , 0, "username", "password")
DirCreate("C:\mis")
FileCopy("X:\vnc.reg", "C:\mis\")
FileCopy("X:\vncreg.bat", "C:\mis\")
FileCopy("X:\instvnc.bat", "C:\mis\")
FileCopy("X:\security.bat", "C:\mis\")
FileCopy("X:\vnc-4_1_1-x86_win32.exe", "C:\mis\")
FileCopy("X:\reg.exe", "C:\mis\")
FileCopy("X:\firewall2013.bat", "C:\mis\")
RunAsSet("Administrator", @Computername, "password")
RunWait("C:\mis\security.bat")
RunWait("C:\mis\instvnc.bat")
RunWait("C:\mis\vncreg.bat")
RunWait("C:\mis\reg.exe")
RunWait("C:\mis\firewall2103.bat")
DriveMapDel("X:")
SplashTextOn("Title", "Your computer will restart In 20 Seconds Please Save and close all Applications .", -1, -1, -1, -1, 4, "", 16)
Sleep(20000)
SplashOff()
RunAsSet()
Shutdown(6)

Share this post


Link to post
Share on other sites
Shane0000

I dont think RunAsSet exists anymore, I think its jus RunAs() now. Do you know where your script fails?

Share this post


Link to post
Share on other sites
sadlerd

It does actually fail at the Line 10 .. which is the RunAsSet  

and I need this to be able to run without prompting any UAC stuff.  This is desigend to "install our VNC" client, and some of the PCS need this info updated, and we can't "remote" them unless the end user can run the .exe to add all the permissions inside the bat files. 

Edited by sadlerd

Share this post


Link to post
Share on other sites
sadlerd

made the change but it gives a  Line 10 Error: Incorrect number of parameters in function call.  Now sure what that means. 

 

DriveMapAdd( "X:", "\\adp2\ad_installs" , 0, "username", "password")
DirCreate("C:\mis")
FileCopy("X:\vnc.reg", "C:\mis\")
FileCopy("X:\vncreg.bat", "C:\mis\")
FileCopy("X:\instvnc.bat", "C:\mis\")
FileCopy("X:\security.bat", "C:\mis\")
FileCopy("X:\vnc-4_1_1-x86_win32.exe", "C:\mis\")
FileCopy("X:\reg.exe", "C:\mis\")
FileCopy("X:\firewall2013.bat", "C:\mis\")
RunAs("Administrator", @Computername, "password")
RunWait("C:\mis\security.bat")
RunWait("C:\mis\instvnc.bat")
RunWait("C:\mis\vncreg.bat")
RunWait("C:\mis\reg.exe")
RunWait("C:\mis\firewall2103.bat")
DriveMapDel("X:")
SplashTextOn("Title", "Your computer will restart In 20 Seconds Please Save and close all Applications .", -1, -1, -1, -1, 4, "", 16)
Sleep(20000)
SplashOff()
RunAsSet()
Shutdown(6)

Share this post


Link to post
Share on other sites
JLogan3o13

It means you aren't calling the parameters correctly. Look at RunAs in the help file, and the associated parameters. Hint: you're missing two


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

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
water

Dog ate your help file?
You need at least 5 parameters:

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

 

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
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
Shane0000

If you dont have a help file the link I supplied shows the help file page for RunAs()

Share this post


Link to post
Share on other sites
sadlerd

Thank You for all the help so far, sorry for all the new questions, i'm very new to AutoIT, and I'm trying to re-write scripts that someone did years ago for Win7. 

 

I was able to get it to run, it creates the Mapped drives, copies over the files. . 

but I think the runas RunAs command to kick the bat files off didn't go as expected.. It didn't install the software.  

Is there another command i'm missing? 

Runas("Administrator", @Computername, "password", 0, "C:\mis\security.bat")
RunAs("Administrator", @Computername, "password", 0, "C:\mis\security.bat")
RunAs("Administrator", @Computername, "password", 0, "C:\mis\instvnc.bat")
RunAs("Administrator", @Computername, "password", 0, "C:\mis\vncreg.bat")
RunAs("Administrator", @Computername, "password", 0, "C:\mis\reg.exe")
RunAs("Administrator", @Computername, "password", 0, "C:\mis\firewall2103.bat"

Share this post


Link to post
Share on other sites
water

Maybe you need to set the working directory for the bat files? Try:

Runas("Administrator", @Computername, "password", 0, "C:\mis\security.bat", "C:\mis\")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
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
JLogan3o13

Also, while this is probably not the answer you're looking for today, in the end you are going to be better off moving all of your batch files to either functions within your AutoIt script or external scripts/UDFs that you can call from your main script. Avoiding the mixture of scripting languages whenever possible will save you a ton of headaches down the road.


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

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
iamtheky

I'm going to guess security is not at the forefront if you are plaintexting an admin username/password (and in autoit land, compiled in an exe also counts as plaintext): 

You have network connectivity to the box, and you cant navigate to any default shares and drop the bats and give yourself rights?


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
jchd

Something else: be sure to use at least the release version of AutoIt, if not the beta.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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

×