How to open with

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
GarryP
Junior Coder
Posts: 27
Joined: Sat Feb 04, 2006 12:01 pm

How to open with

Post by GarryP » Wed Nov 10, 2010 10:20 pm

I hope this hasn't been answered before, but I have not been able to find anything close. I have compiled a macro that creates a new encrypted document in format of "file.xyz" and transmits this file via ftp to a another client. That client has a compiled script that will decrypt the "file.xyz". Currently the client opens the compiled macro and does a file browse to the encrypted file. I would like to define the default program for the .xyz extension to be the compiled macro. If the default program for *.xyz is MyCompiledMacro.exe how can I receive the path and file name of the source file to use with the macro.

Many Thanks,

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Nov 10, 2010 10:53 pm

how can I receive the path and file name of the source file to use with the macro.
Make your compiled macro accept the path/filename as a variable which is passed on the commandline.

i.e.

MyCompiledMacro.exe /MyEncryptedFile=xxxxxxxx

Then in the windows setup for defining a file to be associated with the specific *.xyz file you enter something like the following (this is from memory)

MyCompiledMacro.exe /MyEncryptedFile=%1

To confirm syntax, look at how notepad is associated with *.txt files. It launches them in a similar fashion.

GarryP
Junior Coder
Posts: 27
Joined: Sat Feb 04, 2006 12:01 pm

Post by GarryP » Wed Nov 10, 2010 11:05 pm

Thank you, that should work. I kept trying to figure out how to interpret %1 but I never thought of actually defining a variable via windows file association.

I will try that this evening and post the results.

GarryP
Junior Coder
Posts: 27
Joined: Sat Feb 04, 2006 12:01 pm

Post by GarryP » Thu Nov 11, 2010 12:26 am

That worked, thank you very much. I have defined the windows file association as

"C:\MyDir\MyCompiled.exe" "/source=%1"

But this has lead to another question. I was going to add RegistryReadKey to verify/create the appropriate entries. For some reason, I am unable to read the appropriate registry entries defined as (Default) but I can read any other entry.

I can read
RegistryReadKey>HKEY_CLASSES_ROOT,xyz_auto_file\shell\open\command,Test,registryresulta

but I cannot read
RegistryReadKey>HKEY_CLASSES_ROOT,xyz_auto_file\shell\open\command,(Default),registryresultb

The (default) returns an empty string.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts