Jump to content
Sign in to follow this  
Garp99HasSpoken

Inno Setup registry entries to open multiple files with AU executable

Recommended Posts

Garp99HasSpoken

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
guinness

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
Garp99HasSpoken

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
Garp99HasSpoken

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
Richard Robertson

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
guinness

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
wraithdu

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
guinness

_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
Garp99HasSpoken

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
guinness

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
Garp99HasSpoken

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
guinness

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
Garp99HasSpoken

I was referring to the OP and the registry entry.

Share this post


Link to post
Share on other sites
MHz

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
MHz

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
Garp99HasSpoken

Ok thanks for info, I'll look into it.

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  

  • Similar Content

    • GeorgeB
      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!
       
       
       
       
       
    • cahsobo
      By cahsobo
      Hello,

      I need help inserting these keys and values to registry
       
      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DirectDraw\Compatibility\WK.1.exe]
      "Flags"=hex:00,08,00,00
      "ID"=hex:ec,33,74,3b
       
      Still can't figure out how...
    • nitron
      By nitron
      Hy to all, 
      I am really Sorry to come up with this question but i can't seem to solve the Problem.
      Its quite easy, I have been using RegNumKey for Years, but i seemed to lose track of something.
      For $ZaehlerLocal = 1 to 1200
            $RegKey = RegEnumKey("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall", $ZaehlerLocal)
            If @error <> 0 then ExitLoop
            $RegKey2=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"DisplayName")
            $RegKey3=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"UninstallString")
            $RegKey4=RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"&$RegKey,"QuietUninstallString")

            if StringInStr($RegKey,"_Office15")==0 and StringInStr($RegKey2,"(German) 2013")==0 and StringInStr($RegKey,".KB")==0 and StringInStr($RegKey2,"Security update")==0 and StringInStr($RegKey2,"Framework")==0 Then
              FileWrite($FileHandleLocal,$RegKey&";")
              FileWrite($FileHandleLocal,$RegKey2&";")
              FileWrite($FileHandleLocal,$RegKey3&";")
              FileWriteline($FileHandleLocal,$RegKey4&";")
           EndIf
         Next
       
      Ive been using this to get all uninstall Strings from the Registry but for some reason, this doesn't work anymore. 
      I get some keys but not all, nore does it start with the first registry.
      As you can see in the picture, the Registry starts with {13DA9C7C-EBFB-40D0-94A1-55B42883DF21}
      but RegNumKey starts with Adressbook.
      Any Ideas what I am doing wrong? I tried HKLM64 instead as well, but with same result.
      Again sorry to bother, but i can't Find the mistake.
       

    • Simpel
      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
    • GreenSparks
      By GreenSparks
      Hi!
      I post here because i was wonderring if someone in this forum could help me with my script.
      What i'm trying to do, is to basically install a new keyboard layout in Windows and activate it. I want to acheive by the registry or the command line, but not with the autoit automation tools, i don't find it stable...
      Thanks for your help and have a good day!
×