Jump to content
Sign in to follow this  
Diana (Cda)

AU3 file associations and AutoIt.

Recommended Posts

Diana (Cda)

At work the registry is always locked up wherever I go. Not usu. a problem. Unless I change the folder AutoIt is in so that the original exe path becomes invalid, the file association is usu. achieved by going the old "open with" and choosing the AutoIt executable to always open the app.

However, things like folder name changes or folder moves can happen. Today, the USB flash drive was assigned a different letter so now my scripts don't work. For the most part, I've gotten around that by putting SciTE and AutoIt in the SendTo folder and dumping the scripts into either app depending on what I need to do (edit or run). But I've run into a significant handful of situations where this isn't enough. And since this isn't the first time something like this has happened where AutoIt is no longer found to run AU3s, I'd really like to find a way to fix this. To make things worse, I tried something new today, using "OpenWith" and experimenting with a shortcut to the AI exe but that didn't work and so still stuck as ever. What gets me is that some form of registry editing must be allowed for an app to register file types. Irfanview and CoolPlayer come to mind, freeware apps that you press a button and then they open those files.

Can we do something similar with AutoIt somehow? As I mentioned, registry editing not possible; in fact, trying to launch regedit in a DOS box just brings up an error box advising that action can be done.

Anyway, hoping that someone knows a way; apps can regain control of file types and that seems to not trigger error boxes saying function not possible. Perhaps there's an AutoIt way to do the same thing. I don't need to edit the registry, per se, just to control which apps open what so that I can fix the path to AutoIt for AU3s. Thx. ;)

Share this post


Link to post
Share on other sites
james3mg

Have you tried running a couple regwrite's?

yeah, sounds like your company has disabled access to regedit, rather than disabling write access to the registry...

You'll need to update the path at HKCR\AutoIt3Script\Shell\Run\Command ...be sure to put it in quotes, then a space, then "%1" %* so the entire string will look something like the default:

"C:\Program Files\AutoIt3\AutoIt3.exe" "%1" %*

Similar thing with Compile, Edit and Open (subsituting those values for "Run" in the above registry key path, as well as the correct paths and arguments for each respective command).

Edit: you'll also need to make sure Windows didn't change the file descriptor when you did all your "Open With..." ing. The (Default) value of HKCR\.au3 should be "AutoIt3Script" (no quotes).

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites
Diana (Cda)

yeah, sounds like your company has disabled access to regedit, rather than disabling write access to the registry...

You'll need to update the path at HKCR\AutoIt3Script\Shell\Run\Command ...be sure to put it in quotes, then a space, then "%1" %* so the entire string will look something like the default:

"C:\Program Files\AutoIt3\AutoIt3.exe" "%1" %*
There is light at the end of the tunnel. In last 2 years that I've been using my USB flash drive and using AutoIt as a standalone, on all the locked computers in the places I've worked, sooner or later I have this type of trouble come up, for various reasons. So it's great that there might be a solution, thanks!

I will give this a try. I suspect that the lack of the "path" for the above in regedit is because I stopped installing AI a couple years back since it works perfectly well as a standalone as is; therefore, it's a great tool to have on removable media since relative paths to everything on the removable media is vital (due too Windows drive letter issues). I'm not sure exactly what or how they lock things up, but many program installations don't go through and no .reg files will work.

So, although I searched for the above path in the registry, I didn't find it. Instead, I found this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\AutoIt3.exe\shell\open\command]
@="\"L:\\AutoIt\\APP- AutoIt v3.2.10.0\\AutoIt3.exe\" \"%1\""
and,
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\au3_auto_file\shell\open\command]
@="\"L:\\AutoIt\\APP- AutoIt v3.2.10.0\\AutoIt3.exe\" \"%1\""
Will experiment to see what changes the path at the office.

Similar thing with Compile, Edit and Open (subsituting those values for "Run" in the above registry key path, as well as the correct paths and arguments for each respective command).

Edit: you'll also need to make sure Windows didn't change the file descriptor when you did all your "Open With..." ing. The (Default) value of HKCR\.au3 should be "AutoIt3Script" (no quotes).

The funny thing is that the very first time you tell Windows AutoIt is to open AU3 files, it works. Any subsequent changes never work in XP unless you have access to make changes manually. That's just another funny thing about WinXP. If this workaround does the job of allowing one to change paths to an executable for opening something, it will "revolutionize" things tremendously.

Cheers. ;)

Share this post


Link to post
Share on other sites
Diana (Cda)

Is there such a thing as extracting info from the registry when something like regedit is locked, in terms of what AutoIt can do? Having challenges re which actual key to use as the above one doesn't work (at least on my machine). I could then see what path is actually being used on the computer at work so that I can then modify that registry key. When I used this script above here at home after deleting all references to AI in the registry, it wouldn't work.

Thanks. ;)

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

p.s., in case anyone was wondering, writing an AutoIt file to _set_ a piece of information actually concerning AutoIt in the registry, it's because scripts will work if dumped into a shortcut of the AutoIt executable in the SendTo folder. Just thought I'd make that clearer as, at first glance, this seems to be a funny thing to be doing without knowing that there's another way to make AutoIt work <g>.

Share this post


Link to post
Share on other sites
SmOke_N

I'm curious... is AutoIt installed on this PC?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Diana (Cda)

He/she said that it is on a USB stick.

Yup. On my USB flash drive working as a standalone. But when path is changed, for whatever reason, and initial file association done with OpenWith on the registry no longer is correct, then AI stops working directly. The SendTo dump workaround that I describe above allows one to get scripts to work manually, but all called scripts from a scheduler/launcher fail to work. So it would be really helpful for me to find a solution. I had to plug in another USB device yesterday and the drive letter was changed permanently for my stick. Since the Windows disk management utility isn't available here either, there seems to be no way to change the drive letter back through any of the usual means one would do so.

It took me an hour of testing this morning, but this was only .reg file that worked:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.au3\shell\&Open\command]
@="\"G:\\APPS\\AutoIt\\APP- AutoIt\\AutoIt3.exe\" \"%1\""
What I mean by that is that whenever I deleted all references to AutoIt in the registry at home, a reg file with the above information re-enabled the file association to AutoIt, which I use as a standalone at home, too.

So will now translate this to a regwrite AI script since reg files don't work here at the office, either.

Thanks! ;)

Share this post


Link to post
Share on other sites
Diana (Cda)

Okay, this one took some doing. So far, at home, these 2 scripts below work. I figured it would be good to have one that deletes the key as well.

To add the key:

RegWrite("HKEY_CLASSES_ROOT\.au3\shell\Open\command", "", "REG_SZ", '"L:\AutoIt\APP- AutoIt v3.2.10.0\AutoIt3.exe" "%1"')

At any rate, will take to work tomorrow and change paths there to both apps and then will test it.

<crossing fingers> ;)

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites
Diana (Cda)

Okay, this one took some doing. So far, at home, these 2 scripts below work. I figured it would be good to have one that deletes the key as well.

To add the key:

RegWrite("HKEY_CLASSES_ROOT\.au3\shell\Open\command", "", "REG_SZ", '"L:\AutoIt\APP- AutoIt v3.2.10.0\AutoIt3.exe" "%1"')

At any rate, will take to work tomorrow and change paths there to both apps and then will test it.

<crossing fingers> ;)

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites
MHz

At work the registry is always locked up wherever I go. Not usu. a problem. Unless I change the folder AutoIt is in so that the original exe path becomes invalid, the file association is usu. achieved by going the old "open with" and choosing the AutoIt executable to always open the app.

If you are a limited user then you may only be able to access the HKCU hive. The HKLM hive has precedence over the HKCU hive settings so if you have already have an AU3 file type set by HKLM then the below may not help as you may have not the permission to change HKLM and so HKCU will be over ruled.

I have tested the function but not removing my HKLM keys/values so cannot confirm working operation but see if it helps.

_Register_AutoIt_Association('HKCU', 'G:\APPS\AutoIt\APP- AutoIt\AutoIt3.exe')

Func _Register_AutoIt_Association($hive, $fullpath, $write = True)
    Local $association = 'AutoIt3Script'
    ; choose the registry hive to use
    Switch $hive
        Case 'HKCU', 'HKEY_CLASSES_ROOT'
            $key = 'HKCU\Software\Classes'; current user only
        Case 'HKLM', 'HKEY_LOCAL_MACHINE', 'HKCR', 'HKEY_CLASSES_ROOT'
            $key = 'HKLM\Software\Classes'; system wide use
        Case Else
            Return
    EndSwitch
    ; Handle the registry write or remove stuff below
    If $write Then
        ; write the file type into registry with association pointer
        RegWrite($key & '\.au3', '', 'REG_SZ', $association)
        ; write the association to registry
        RegWrite($key & '\' & $association & '\Shell\Open\Command', '', 'REG_SZ', '"' & $fullpath & '" "%1"')
    Else
        ; remove file type
        RegDelete($key & '\.au3')
        ; remove association
        RegDelete($key & '\' & $association)
    EndIf
EndFunc

My effort was mild so you could probably enhance it if it works for you. ;)

Share this post


Link to post
Share on other sites
Anteaus

Don't know if it's of any help but I use Altap Salamander as my working environment, with usermenu items for the various compiler versions, and F3 for SciTe, F4 for UltraEdit. Working this way means that your sourcecode driveletter is unimportant, in fact you can compile scripts remotely across the LAN, which is handy for testing. Salamand.exe can be run directly from the commandline (with the zipped version) if you are not allowed to install programs.

http://www.altap.cz

The free version will do what you need, though the paid version is hardly expensive and has quite a few useful extras, like opening of almost every known type of archive file, preview of docs, images, etc. The paid version will also save its settings to a config-file if necessary.

-BTW, the usermenu item for a compiler is of the form:

{path}\Aut2exe[A].exe /in "%f" [/pass] [password] ([]=optional)

While that for an interpreter is:

{path}\Autoit3[A].exe "%f"

Edited by Anteaus

Share this post


Link to post
Share on other sites
Diana (Cda)

Well, I'll be damned ... !

I don't know if this is breaking a whole bunch of rules, it doesn't seem right somehow but I found a workaround. I know that sooner or later other people may find themselves in this situation, so good to put all possible solutions here.

But first, I'm thinking that the HKCU vs HKLM is the most probable reason why my test didn't work. I'm thinking this because I've never checked to see if the "OpenWith" method of achieving AutoIt file association left an entry in the context menu saying "Open". Somehow, I doubt it. I've never paid attention to what gets dumped into the context menu for .AU3 but I'm guessing that it's a default blank entry. After trying my RegWrite test this morning after modifying the path to the AutoIt3.exe, I found a bolded "Open" in the context. So it would seem that that part, at least, works. But I'm guessing that the unknown previous entry that isn't working is taking precedence which is why the test didn't work.

In the meantime, however, I got a crazy idea after this failure that seems to be working: I made a copy of the "AutoIt3.exe" and renamed it to "AutoIt3_No.2.exe" and re-assigned association to AutoIt that way through "OpenWith". This time, the change appeared in that box that "OpenWith" brings up and I was thus able to get my AutoIt back. I just don't know how well the differently named copy will handle AI tasks. So far, so good, but don't know how "illegal" an operation this is. I'm guessing that since I'm now able to use AutoIt again that the coding for this fantastic program is flexible enough to handle the different name, but I'm still curious about this.

For now, will leave things as they are.

The thing to do in the future, though, is to see if the RegWrite file works from the outset in this type of situation and not get file association via "OpenWith". If it does, then when things change, the RegDelete should work and then I can modify the original RegWrite file accordingly and re-apply the file association to the modified path.

Thanks! Will report back. ;)

p.s., Thanks! I'll go through and test out the this "_Register_AutoIt_Association". That sounds intriguing. I'll bet I'll learn more neat stuff by checking it out.

Share this post


Link to post
Share on other sites
Diana (Cda)

Don't know if it's of any help but I use Altap Salamander as my working environment, with usermenu items for the various compiler versions, and F3 for SciTe, F4 for UltraEdit. Working this way means that your sourcecode driveletter is unimportant, in fact you can compile scripts remotely across the LAN, which is handy for testing. Salamand.exe can be run directly from the commandline (with the zipped version) if you are not allowed to install programs.

http://www.altap.cz

The free version will do what you need, though the paid version is hardly expensive and has quite a few useful extras, like opening of almost every known type of archive file, preview of docs, images, etc. The paid version will also save its settings to a config-file if necessary.

-BTW, the usermenu item for a compiler is of the form:

{path}\Aut2exe[A].exe /in "%f" [/pass] [password] ([]=optional)

While that for an interpreter is:

{path}\Autoit3[A].exe "%f"

Wow, thanks. This sounds like an interesting idea. I'm guessing that it's a file manager/windows explorer replacement? I remember using various famous apps of this type, i.e., Servant Salamander. I must have tried about 30-40 different ones before settling with PowerDeskPro. But I'm always on the lookout esp. if it can handle things like this. The interesting thing to see is how well it works as a portable app since most of the professed portables are really just plain old ordinary standalones that fail pretty dismally when put to the test of working on different drive letters.

I'll have to see also how the freeware compares to the payware. That might be a problem as I prefer freeware. But will definitely check it out.

Thanks. ;)

Share this post


Link to post
Share on other sites
Diana (Cda)

Wow, thanks. This sounds like an interesting idea. I'm guessing that it's a file manager/windows explorer replacement? I remember using various famous apps of this type, i.e., Servant Salamander.

<lol> I should have checked first. It is Servant Salamander!

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.