Jump to content

Adding resources to compiled scripts


Recommended Posts

So after some searching in this forum, I can't seem to find an answer to this question:

When I add options like this in my AutoIt scripts:

#AutoIt3Wrapper_res_File_Add=secedit.exe
#AutoIt3Wrapper_res_File_Add=subinacl.exe

I assumed that these files were added as resources into the final, compiled executable. This does not appear to be the case. The program can reference these files easily, but if the file does not reside in the directory the program is in, these external programs will not run.

Explanation (to assuage any concerns of malicious intent):

I am attempting to write a simple tool to automate some of the fixes that I have to run quite often at work (repairing windows update, windows installer, etc.) and two of these simple fixes are to system-wide ACLs and to security permissions. Both of these fixes require _RunDOS commands similar to:

subinacl.exe /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f

Or:

secedit.exe /analyze /db C:\Windows\sectest.db /cfg C:\Windows\inf\defltwk.inf /log C:\Windows\security\logs\secanalyze.log

Naturally, I need both subinacl.exe and secedit.exe to run these commands. Neither of these files are installed in Windows by default. Ideally, I'd like this script to run from a network share so I don't have to carry it around the office with me. Unfortunately, this means that I'm using temporary UNC path names to access the script, which plays havoc with these two programs path names and makes it so they don't run.

If there were a way to make it so these two programs were part of the final, compiled script, I would be ecstatic. I did read about the "FileInstall" function, but that doesn't seem to work.

Any help I could get with this question would be greatly appreciated.

Also, if any one is curious, I'd be happy to post the script in its entirety for your own perusal or use.

Link to comment
Share on other sites

FileInstall is the easiest way to go, so what was the issue with FileInstall()?

I guess I don't entirely understand how the

#AutoIt3Wrapper_res_File_Add=

compilation option works. Is the file embedded as a resource at that point? From basic file sizes (compiled with and without the option), it certainly doesn't look like it...

(P.S. This is an amazing development platform for IT work. You guys are kind of my heroes right now, and you're making me look really good in my boss's eyes...)

Edited by jwseek
Link to comment
Share on other sites

Right. But where does FileInstall() pull its files to install from? Because the file I need to install likely won't be on the target computer, I need to have it with me somehow. Ideally, this would be bundled in the executable.

Link to comment
Share on other sites

Right. But where does FileInstall() pull its files to install from? Because the file I need to install likely won't be on the target computer, I need to have it with me somehow. Ideally, this would be bundled in the executable.

FileInstall() does bundle the program into the executable. FileInstall takes the file you specify (at compilation time - so the program you specify would be pulled from the machine you are compiling on), wraps it up into the AutoIt program, then extracts it to whichever directory you specify on the machine the program is run on (i.e. a temp directory).
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

  • Developers

Did you check the Helpfile?

The Sourcefile is included in the target EXE at Compilation time and the second parameter determines at execution time where the file is extracted too.

Usualy you use @TempDir to ensure the user has write access.

:)

FileInstall

--------------------------------------------------------------------------------

Include and install a file with the compiled script.

FileInstall ( "source", "dest" [, flag] )

Parameters

source The source path of the file to compile. This must be a literal string; it cannot be a variable.

dest The destination path of the file with trailing backslash if only the directory is used. This can be a variable.

flag [optional] this flag determines whether to overwrite files if they already exist:

0 = (default) do not overwrite existing files

1 = overwrite existing files

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

As I am impatient and other derogatory adjectives, I neglected to properly test the FileInstall() function. Looks like that one works perfectly. I don't know why I didn't try it more before bothering everyone.

Either way, thank you very much for your help, and I guess I'll keep hacking away at this thing...

And for fun, try out the script and see what you think. Basically it's a simplified and updated Dial-a-Fix with a bunch of extra repairs.

RepairTool.au3

Link to comment
Share on other sites

Well that's reassuring. I've only been using this language for a little while, I was worried I'd have horridly trashed and ugly code.

Of course, I could actually be commenting my code better...

Link to comment
Share on other sites

  • Developers

Well that's reassuring. I've only been using this language for a little while, I was worried I'd have horridly trashed and ugly code.

Of course, I could actually be commenting my code better...

I can tell you are not new to coding else there wouldn't have been any: Comment,Indenting, Regions ...etc :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...