Jump to content

Script Help


Recommended Posts

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)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • Moderators

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

"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

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

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

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

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.

"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

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?

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

Link to comment
Share on other sites

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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...