Jump to content
Sign in to follow this  
Garp99HasSpoken

Inno Setup registry entries to open multiple files with AU executable

Recommended Posts

I have the following [Registry] entry in an Inno Setup .iss file

; TV convert filters (Extra 2)
Root: HKCR; Subkey: "*\shell\{#MyAppName}{#MyExtra2}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppTitle} {#MyExtra2}"; Flags: uninsdeletekey
Root: HKCR; Subkey: "*\shell\{#MyAppName}{#MyExtra2}\DefaultIcon"; ValueType: expandsz; ValueName: ""; ValueData: "{app}\{#MyAppExeName},-5"; Flags: uninsdeletekey
Root: HKCR; Subkey: "*\shell\{#MyAppName}{#MyExtra2}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""/f"" ""{app}\{#MyAppName}{#MyFilter}.txt"" ""/ni"" ""%1"" ""%2"" ""%3"" ""%4"" ""%5"" ""%6"" ""%7"" ""%8"" ""%9"""; Flags: uninsdeletekey
Root: HKCR; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppTitle} {#MyExtra2}"; Flags: uninsdeletekey
Root: HKCR; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}\DefaultIcon"; ValueType: expandsz; ValueName: ""; ValueData: "{app}\{#MyAppExeName},-5"; Flags: uninsdeletekey
Root: HKCR; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""/f"" ""{app}\{#MyAppName}{#MyFilter}.txt"" ""/ni"" ""%1"" ""%2"" ""%3"" ""%4"" ""%5"" ""%6"" ""%7"" ""%8"" ""%9"""; Flags: uninsdeletekey

Root: HKCU; Subkey: "*\shell\{#MyAppName}{#MyExtra2}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppTitle} {#MyExtra2}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "*\shell\{#MyAppName}{#MyExtra2}\DefaultIcon"; ValueType: expandsz; ValueName: ""; ValueData: "{app}\{#MyAppExeName},-5"; Flags: uninsdeletekey
Root: HKCU; Subkey: "*\shell\{#MyAppName}{#MyExtra2}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""/f"" ""{app}\{#MyAppName}{#MyFilter}.txt"" ""/ni"" ""%1"" ""%2"" ""%3"" ""%4"" ""%5"" ""%6"" ""%7"" ""%8"" ""%9"""; Flags: uninsdeletekey
Root: HKCU; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppTitle} {#MyExtra2}"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}\DefaultIcon"; ValueType: expandsz; ValueName: ""; ValueData: "{app}\{#MyAppExeName},-5"; Flags: uninsdeletekey
Root: HKCU; Subkey: "Directory\shell\{#MyAppName}{#MyExtra2}\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""/f"" ""{app}\{#MyAppName}{#MyFilter}.txt"" ""/ni"" ""%1"" ""%2"" ""%3"" ""%4"" ""%5"" ""%6"" ""%7"" ""%8"" ""%9"""; Flags: uninsdeletekey

"C:\Program Files (x86)\VideoRename\VideoRename.exe" "/f" "C:\Program Files (x86)\VideoRename\VideoRenameFilters.txt" "/ni" "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

The items in ValueData are being properly set in the Windows 7 registry and the parameters are passed except only *one* file is being passed to the executable.

Basically, in Windows Explorer I select 2 (or more) files and right-click to get context menu, select my AU compiled program, and I want my program to execute with the files passed in.

The problem is that my program is called for each file individually.

I expected the "%2", etc to work for up to 9 parameters/files to be passed in. Double-quotes are in case of spaces in the full path of the filenames.

What have I missed?

What else can I try?

Share this post


Link to post
Share on other sites

What have I missed?

What else can I try?

It won't work like that without creating a shell extension handler.

A workaround I created >>


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Done some reading of the threads, and the example of registering the program which opens Notepad.

Do I understand this correctly...?

I need to use your example as a front-end program to my program (not Notepad) which will grab the file names and

pass these along to my program. So in effect, the right-click context menu entry in the registry will be the front-end program

which is what the user will see, and when the user selects 2+ files/folders, it will pass these along to my real program.

Edited by Garp99HasSpoken

Share this post


Link to post
Share on other sites

After getting the example code incorporated into my code, I see that what I called a front-end above is more like a daemon process that needs to be started up and then sits around waiting for 1 or more files passed to it with the context menu.

I run into a few problems with this method:

- first I need a way for adding the program to Windows Start-up folder which I might be able to figure out with Inno Setup

- once started, it conflicts with the same program but with different parameters passed in. I add 3 entries into the registry for the same program name but extra parameters (different config file) and options. Using the example code, I see the first entry's context menu change to "Start my prog" but the other two are unchanged. When the daemon running, the first option correctly passes only the new file names as expected.

Using the second two options will pass all the parameters as a file name, so instead of "Filename", I get "-f C:Program Files (x86)VideoRenameVideoRenameFilters.txt /ni Filename"

I will have to re-think how to best handle this -- multiple versions of the same program but different names perhaps.

Share this post


Link to post
Share on other sites

A simpler solution is to let them each open a fresh process, but check to see if a process is already running and use IPC to pipe all the new filenames to it. For a more advanced mechanism, you could add a check to see when the last process was started instead of blinding referring all new files to the old process if you wanted to allow running more than one at a time.

Share this post


Link to post
Share on other sites

A simpler solution is to let them each open a fresh process, but check to see if a process is already running and use IPC to pipe all the new filenames to it. For a more advanced mechanism, you could add a check to see when the last process was started instead of blinding referring all new files to the old process if you wanted to allow running more than one at a time.

Kind of how I did it in that example but I send the WM_COPYDATA to the first process.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

There are other limitations to context menus, such as the total number of items you can select and operate upon (15 I believe). You might be better off to alter your workflow and use the Send to menu. There is no restriction to the number of files to act upon, and they are all sent in a single command.

Edited by wraithdu

Share this post


Link to post
Share on other sites

_SendTo and _Startup UDFs in my signature.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

I will investigate the suggestions.

SendTo would be more inconvenient as it requires going into a submenu, but still possible if more than 1 file passed.

guinness, the example opens up Notepad to get a windows handle, how do I create an empty handle if I want it to be a non-gui daemon process?

Share this post


Link to post
Share on other sites

I would just use SendTo.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

Ok.

Just FYI, a weird thing that I see in your Notepad example is that 11 parameters are passed in "-f filter.txt File1 empty2 empty3...empty9" which implies the "%1 %2 ... %9" is used but the passed in filenames are not substituted in for them.

Share this post


Link to post
Share on other sites

Just FYI, a weird thing that I see in your Notepad example is that 11 parameters are passed in "-f filter.txt File1 empty2 empty3...empty9" which implies the "%1 %2 ... %9" is used but the passed in filenames are not substituted in for them.

I don't pass such parameters like that in my example, sorry. Perhaps you're talking about a different example?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

AFAIK, %1 is the parameter used to get all parameters passed. There is also %* though I have never found it to do anything. A cmd script does the %0 to %9 parameters so do not consider that the registry will behave the same. When the registry with %1 expands to multiple paths being passed then an executable will be opened multiple times. This is where context menu handlers (extensions) are used. The handlers reside in memory just to handle the tasks like multiple paths used in %1. So that is the choice you have.

As for your registry entries. Now, they are a concern. When you write filetypes and associations, then you have 2 places to write them.

HKCU\Software\Classes

HKLM\Software\Classes

HKCR is a merging of those 2 places so you can get to read the association without the need to read from multiple places.

Here is a quote from here that I found as reference

Important considerations about file types include:

  • The HKEY_CLASSES_ROOT subtree is a view formed by merging HKEY_CURRENT_USER\Software\Classes and HKEY_LOCAL_MACHINE\Software\Classes
  • In general, HKEY_CLASSES_ROOT is intended to be read from but not written to. For more information, see the HKEY_CLASSES_ROOT article.
  • To register a file type globally on a particular computer, create an entry for the file type in the HKEY_LOCAL_MACHINE\Software\Classes subkey.
  • To make a file type registration visible to the current user only, create an entry for the file type in the HKEY_CURRENT_USER\Software\Classes subkey.
  • An application can provide its own implementation of a verb, such as open or play, as shown in the following registry example.

Now, if you write to HKCR then undesirable results can happen. If the registry has the keys and values in HKCU\Software\Classes and you wanted to write them to HKLM\Software\Classes then HKCR will write them to the keys and values in HKCU\Software\Classes instead as the later has higher priorty. Thus it is a grave mistake to write to HKCR.

Here is a example I created to prove this. It has #RequireAdmin, so you may need to run Scite as admin to see the consolewrites.

#RequireAdmin
; run scite as admin to see the ConsoleWrite

Global $old_value[3]
Global $new_value[3]

; HKLM write
If RegWrite('HKLM\SOFTWARE\CLASSES\.abcdef', '', 'REG_SZ', 'HKEY_LOCAL_MACHINE') Then
    _ReadAndMessage('HKLM write. OK')
EndIf

; HKCR write changes HKLM
If RegWrite('HKCR\.abcdef', '', 'REG_SZ', 'HKEY_CLASSES_ROOT') Then
    _ReadAndMessage('HKCR write. Changes HKLM. OK')
EndIf

;~ ; HKLM write again
If RegWrite('HKLM\SOFTWARE\CLASSES\.abcdef', '', 'REG_SZ', 'HKEY_LOCAL_MACHINE') Then
    _ReadAndMessage('HKLM write again. OK')
EndIf

; HKCU write
If RegWrite('HKCU\SOFTWARE\CLASSES\.abcdef', '', 'REG_SZ', 'HKEY_CURRENT_USER') Then
    _ReadAndMessage('HKCU write. OK')
EndIf

; HKCR write changes HKCU
If RegWrite('HKCR\.abcdef', '', 'REG_SZ', 'HKEY_CLASSES_ROOT') Then
    _ReadAndMessage('HKCR write. Changes HKCU. Not OK if you wanted HKLM to change')
EndIf

$type = '.abcdef'
$assoc = _Comspec('assoc .abcdef')
ConsoleWrite('--- Assoc returns' & @CRLF)
ConsoleWrite($assoc & @CRLF)

RegDelete('HKLM\SOFTWARE\CLASSES\.abcdef')
RegDelete('HKCU\SOFTWARE\CLASSES\.abcdef')

Exit

Func _ReadAndMessage($message)
    $new_value[0] = RegRead('HKCR\.abcdef', '')
    $new_value[1] = RegRead('HKCU\SOFTWARE\CLASSES\.abcdef', '')
    $new_value[2] = RegRead('HKLM\SOFTWARE\CLASSES\.abcdef', '')
    $string = ( _
        $message & @CRLF & _
        StringFormat('%-8s %-22s %-7s', 'HKCR', $new_value[0], _Changed($old_value[0], $new_value[0])) & @CRLF & _
        StringFormat('%-8s %-22s %-7s', 'HKCU', $new_value[1], _Changed($old_value[1], $new_value[1])) & @CRLF & _
        StringFormat('%-8s %-22s %-7s', 'HKLM', $new_value[2], _Changed($old_value[2], $new_value[2])) & @CRLF _
    )
    ConsoleWrite('--- ' & $string & @CRLF)
    $old_value = $new_value
;~     MsgBox(0x40000, @ScriptName, $string)
EndFunc

Func _Changed($value1, $value2)
    If $value1 == $value2 Then
        Return ''
    Else
        Return 'Changed'
    EndIf
EndFunc

Func _Comspec($parameter = '')
    Local $output, $pid
    $pid = Run('"' & @ComSpec & '" /c ' & $parameter, '', @SW_MINIMIZE, 2)
    Do
        Sleep(10)
        $output &= StdOutRead($pid)
    Until @error
    Return $output
EndFunc

The output will be

--- HKLM write. OK

HKCR HKEY_LOCAL_MACHINE Changed

HKCU

HKLM HKEY_LOCAL_MACHINE Changed

--- HKCR write. Changes HKLM. OK

HKCR HKEY_CLASSES_ROOT Changed

HKCU

HKLM HKEY_CLASSES_ROOT Changed

--- HKLM write again. OK

HKCR HKEY_LOCAL_MACHINE Changed

HKCU

HKLM HKEY_LOCAL_MACHINE Changed

--- HKCU write. OK

HKCR HKEY_CURRENT_USER Changed

HKCU HKEY_CURRENT_USER Changed

HKLM HKEY_LOCAL_MACHINE

--- HKCR write. Changes HKCU. Not OK if you wanted HKLM to change

HKCR HKEY_CLASSES_ROOT Changed

HKCU HKEY_CLASSES_ROOT Changed

HKLM HKEY_LOCAL_MACHINE

--- Assoc returns

.abcdef=HKEY_LOCAL_MACHINE

The 1st HKCR write is OK if you meant it to write to HKLM\Software\Classes. The 2nd HKCR write is not as it writes to HKLM\Software\Classes instead. So you may notice that HKCR is a mixture of both of the classes and writing to them is unknown from a script to where the entries may go to.

As for the Send To idea. It can handle muliple parameters as it is a context menu handler. It does have a limit on how many parameters you can pass. Been awhile since I last tested it though it maybe something like 1024 chars or number near that range on Vista/7. XP does much better and could do many times more, so take note of that when testing.

Share this post


Link to post
Share on other sites

Correction on last post. The forum messes the code on reedit I notice so reposting the edit here.

The statement near the end

The 1st HKCR write is OK if you meant it to write to HKLMSoftwareClasses. The 2nd HKCR write is not as it writes to HKLMSoftwareClasses instead. So you may notice that HKCR is a mixture of both of the classes and writing to them is unknown from a script to where the entries may go to.

should be

The 1st HKCR write is OK if you meant it to write to HKLMSoftwareClasses. The 2nd HKCR write is not as it writes to HKCUSoftwareClasses instead. So you may notice that HKCR is a mixture of both of the classes and writing to them is unknown from a script to where the entries may go to.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By joseLB
      Hi
      This piece of code creates and reads OK a key at  "HKEY_LOCAL_MACHINE" and can be changed for a key at "HKEY_CURRENT_USER"
      $sta= RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor", "wav", "REG_SZ", "5555") MsgBox(4096,"wrote", $sta &@cr& @error) $zz= RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor", "wav") MsgBox(4096,"readed","="&$zz &@cr& @error) Exit With  HKEY_CURRENT_USER, in RegEdit we can see the created key, and we can create the key by hand/RegEdit and everything Works OK.
      At  HKEY_LOCAL_MACHINE we can´t see the created key above  thru RegEdit, but it Works (even not seeing, I can read). But  if I create "by hand"/RegEdit  the key,  it can´t read it with   $zz= RegRead  ("HKEY_LOCAL_MACHINE.... above.
      I´m the PC´s WIN.7 administrator. Even so I ran RegEdit as administrator and also the compiled AU3 and also plain. No changes.
      edit: even if Try   "HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav", the same holds true.
      $sta= RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav", "REG_SZ", "4444") MsgBox(4096,"wrote", $sta &@cr& @error) $zz= RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\AAA", "wav") MsgBox(4096,"readed","="&$zz &@cr& @error) Exit Seems that it creates this key at another place.... I can read the above value ("4444"), even after a boot, even the key not showing in regedit. And if I create it by hand key AAA/wav with a distinct value (666), t, it continues Reading the old value = 444.
      Thanks
      Jose
       
    • By nacerbaaziz
      good morning everybody.
      today i liked to share an small example with you
      which it an function to read the registry values as an array
      the result array is 2d array witch
      $a_array[n][0] = value name
      $a_array[n][1] = value Data
      $a_array[0][0] = values count
      here's the function

      #include <Array.au3> #include <WinAPIReg.au3> #include <APIRegConstants.au3> Local $a_array = _RegReadToArray("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") If @error Then     MsgBox(16, "error", @error)     Exit EndIf _ArrayDisplay($a_array) Func _RegReadToArray($s_RegKey)     Local $a_KeySplitInfo = StringSplit($s_RegKey, "\\", 2)     If UBound($a_KeySplitInfo) <= 1 Then         $a_KeySplitInfo = StringSplit($s_RegKey, "\", 2)         If UBound($a_KeySplitInfo) <= 1 Then Return (1, 1, 0)     EndIf     Local $H_KeyInfo = "", $s_RegKeyInfo = ""     Switch $a_KeySplitInfo[0]         Case "hklm", "HKEY_LOCAL_MACHINE", "hklm64", "HKEY_LOCAL_MACHINE64"             $H_KeyInfo = $HKEY_LOCAL_MACHINE         Case "hkCu", "HKEY_CURRENT_USER", "hkCU64", "HKEY_CURRENT_USER64"             $H_KeyInfo = $HKEY_CURRENT_USER         Case "hkCr", "HKEY_CLASSES_ROOT", "HKCR64", "HKEY_CLASSES_ROOT64"             $H_KeyInfo = $HKEY_CLASSES_ROOT         Case "HKU", "HKEY_USERS", "HKU64", "HKEY_USERS64"             $H_KeyInfo = $HKEY_USERS         Case Else             Return SetError(2, 2, 0)     EndSwitch     _ArrayDelete($a_KeySplitInfo, 0)     $s_RegKeyInfo = _ArrayToString($a_KeySplitInfo, "\")     Local $H_KeyInfoOpen = _WinAPI_RegOpenKey($H_KeyInfo, $s_RegKeyInfo, $KEY_READ)     Local $A_KeyInfo = _WinAPI_RegQueryInfoKey($H_KeyInfoOpen)     If @error Then Return SetError(1, 1, 0)     _WinAPI_RegCloseKey($H_KeyInfoOpen)     Local $A_RegVal[$A_KeyInfo[2] + 1][2]     Local $iV = 1, $s_RegRead = ""     While 1         $s_RegVal = RegEnumVal($s_RegKey, $iV)         If @error <> 0 Then ExitLoop         $s_RegRead = RegRead($s_RegKey, $s_RegVal)         If Not (@error) Then             $A_RegVal[$iV][0] = $s_RegVal             $A_RegVal[$iV][1] = $s_RegRead         EndIf         $iV += 1     WEnd     $A_RegVal[0][0] = UBound($A_RegVal) - 1     If $A_RegVal[0][0] >= 1 Then         Return $A_RegVal     Else         Return SetError(3, 3, 0)     EndIf EndFunc   ;==>_RegReadToArray
      i hope you benefit from it
      with my greetings
    • By Simpel
      Hi,
      I wondered why negative integers I wrote into registry (e.g. negative x-coordinates of a gui if using two monitors and the right one is the main one) wouldn't return right when reading. Now I know: it is saved as an unsigned integer (without algebraic sign). So here is a snippet that is changing unsigned to signed integer:
      Global Const $g_sRegKey = "HKEY_CURRENT_USER\Software\" & @ScriptName ; path to registry RegWrite($g_sRegKey, "Value", "REG_DWORD", -2147483647) ; write some negative integer into registry; -2147483647 highest possible negative integer , 2147483648 highest possible positive integer if talking of 32bit Local $sValue = RegRead($g_sRegKey, "Value") ; read out registry ConsoleWrite("Value: " & $sValue & @CRLF) ; show real value in console Local $sResult = _SignedInteger($sValue) ; change to signed value ConsoleWrite("Result: " & $sResult & @CRLF) ; and show it in console Func _SignedInteger($iUnsignedInteger) Local $iSignedInteger If $iUnsignedInteger > (2^31) Then ; then it means a negative integer $iSignedInteger = $iUnsignedInteger - (2^32) Else $iSignedInteger = $iUnsignedInteger EndIf Return $iSignedInteger EndFunc It took me some time to find out the problem and so I hope I can help somebody with this.
      Regards, Conrad
    • By copyleft
      I've looked at a bunch of SetACL examples on this site and none seem to be able to convert this batch script into a working AutoIt script.
      BATCH
      @echo off "%~dp0setacl.exe" -on "HKEY_CLASSES_ROOT\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon" -ot reg -actn setowner -ownr n:administrators >nul 2>nul "%~dp0setacl.exe" -on "HKEY_CLASSES_ROOT\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon" -ot reg -actn ace -ace "n:administrators;p:full" >nul 2>nul Reg.exe add "HKCR\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon" /ve /t REG_EXPAND_SZ /d "C:\My.ico" /f NON-WORKING AUTOIT
      RunWait('setacl.exe "HKCR64\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon" -ot reg -actn setowner -ownr "n:administrators"') RunWait('setacl.exe "HKCR64\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon" -ot reg -actn setowner -ownr "n:administrators;p:full"') RegWrite('HKCR64\CLSID\{9C60DE1E-E5FC-40f4-A487-460851A8D915}\DefaultIcon', '','REG_EXPAND_SZ','C:\Windows\My.ico') Any ideas on what I'm doing wrong?
       
    • By GeorgeB
      I'm writing a little applet that basically tells you when Windows was installed.  There is a REG_DWORD in Windows that gives you this. It's basically a value that is the # of seconds from 1970.
      The location is:  "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate"
      So if I run this in AutoIT, I should get the value displayed within the msgbox:
      MsgBox($MB_SYSTEMMODAL, "InstallDate Test", RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "InstallDate"))
      However, what happens is it always returns a value of "0"  I tried this on several machines (Windows 8, Windows 8.1 and Windows 10). 
      Am I missing something?  If I manually view this REG_DWORD with RegEdit, it shows me the HEX value, or I can view the Decimal value. I don't care which value AutoIT reads, as I can always convert back and forth, but I just don't see why it can't read a value from this REG_DWORD.  As a test, I've read other REG_DWORD values, and with most it doesn't return any value, not even a 0.
      Please, even if you guys have some other (perhaps better) way to read the Windows install date, I would still like to find a resolution to this problem, because I want to understand why I am having so much difficulty with reading REG_DWORD values from the Windows Registry with AutoIT.
      Thanks for any help!
       
       
       
       
       
×
×
  • Create New...