youtuber Posted March 13, 2021 Posted March 13, 2021 (edited) There is a portable program. When this program runs, it leaves no other traces in the MuiCache registry key. There are two versions of the program, Beta and Release. I need to check the existence of Plugin.pl file. If there is a plug-in in both folders, the file path has after loop (MyPluginC:\) merged problem, the following sample codes are available. expandcollapse popup#RequireAdmin #cs Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache] "C:\\Users\\USER\\Desktop\\Program\\GeneralPurposeAppz\\Beta\\my.exe"="my.exe" "C:\\Users\\USER\\Desktop\\Program\\GeneralPurposeAppz\\Release\\my.exe"="my.exe" "LangID"=hex:1f,04 #ce Local $Enum = 0 Local $sSubkey $found = "" Local $sKey = "HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" While 1 $Enum = $Enum + 1 $sSubkey = RegEnumVal($sKey, $Enum) If @error <> 0 Then ExitLoop Else If StringInStr($sSubkey, "my.exe") Then If FileExists($sSubkey) Then $Replace = StringReplace($sSubkey, "my.exe","") If FileExists($Replace & "MyPlugin\plugin.pl") Then $found &= $Replace ;ConsoleWrite($found & @CRLF) Else $found &= "No plugin.pl found" EndIf EndIf EndIf EndIf WEnd If StringInStr($found, "\GeneralPurposeAppz\") Then ConsoleWrite("$found : " & $found & @CRLF) ;--------------------------------- ;C:\Users\USER\Desktop\Program\GeneralPurposeAppz\Beta\C:\Users\USER\Desktop\Program\GeneralPurposeAppz\Release\ ;The problem is exactly that ShellExecute won't run because it gives an error. ShellExecute($found & "MyPlugin\") ;---------------------------------- Else MsgBox(48,"Not found", $found) EndIf Edited March 13, 2021 by youtuber
Subz Posted March 13, 2021 Posted March 13, 2021 You are concatenating without adding an @CRLF to $found, so will just display one line $found &= $Replace ;Use: $found &= $Replace & @CRLF You also appear to have different format for MuiCache, I see values with .ApplicationCompany and .FriendlyAppName for example: C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe.ApplicationCompany C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe.FriendlyAppName To get the path and filename (with or without the .ApplicationCompany or .FriendlyAppName) you could use something like: $aSubkey = StringRegExp($sSubkey, "(.*\\(?:[^.]*$)?)(.*\.exe)", 3) If Not @error Then ConsoleWrite("Directory : " & $aSubkey[0] & @CRLF & "Filename : " & $aSubkey[1] & @CRLF) EndIf youtuber 1
youtuber Posted March 13, 2021 Author Posted March 13, 2021 @Subz Windows 7 looks different too Windows 7 : https://prnt.sc/10kx0m8 Windows 10 : https://prnt.sc/10kwxko
youtuber Posted March 14, 2021 Author Posted March 14, 2021 The problem continues. Gives "Windows cannot find" error in ShellExecute command. https://prnt.sc/10lmubx #RequireAdmin Local $Enum = 0 Local $sSubkey $found = "" Local $sKey = "HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" While 1 $Enum = $Enum + 1 $sSubkey = RegEnumVal($sKey, $Enum) If @error <> 0 Then ExitLoop Else If StringInStr($sSubkey, "my.exe") Then $aSubkey = StringRegExp($sSubkey, "(.*\\(?:[^.]*$)?)(.*\.exe)", 3) If Not @error Then If FileExists($aSubkey[1]) Then ConsoleWrite($aSubkey[1] & @CRLF) ;ConsoleWrite("Directory : " & $aSubkey[0] & @CRLF & "Filename : " & $aSubkey[1] & @CRLF) If FileExists($aSubkey[0] & "MyPlugin\plugin.pl") Then $found &= $aSubkey[0] & @CRLF ConsoleWrite($found & @CRLF) EndIf EndIf EndIf EndIf EndIf WEnd If StringInStr($found, "\GeneralPurposeAppz\") Then ;ConsoleWrite("$found : " & $found & @CRLF) ShellExecute($found & "MyPlugin\") Else MsgBox(48, "Not found", $found) EndIf
Subz Posted March 14, 2021 Posted March 14, 2021 So on Windows 10 you would need to detect if that folder has already been found, you would also need to separate variables to hold Beta and Release directory Example: (Untested) #RequireAdmin Local $Enum = 0 Local $sSubkey Local $sBetaDir, $sReleaseDir Local $sKey = "HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache" While 1 $Enum = $Enum + 1 $sSubkey = RegEnumVal($sKey, $Enum) If @error <> 0 Then ExitLoop Else If StringInStr($sSubkey, "my.exe") Then $aSubkey = StringRegExp($sSubkey, "(.*\\(?:[^.]*$)?)(.*\.exe)", 3) If Not @error Then If FileExists($aSubkey[1]) Then ConsoleWrite($aSubkey[1] & @CRLF) ;ConsoleWrite("Directory : " & $aSubkey[0] & @CRLF & "Filename : " & $aSubkey[1] & @CRLF) If FileExists($aSubkey[0] & "MyPlugin\plugin.pl") Then If StringInStr($aSubkey[0], "\GeneralPurposeAppz\Beta\") > 0 And $sBetaDir <> $aSubkey[0] Then $sBetaDir = $aSubkey[0] If StringInStr($aSubkey[0], "\GeneralPurposeAppz\Release\") > 0 And $sReleaseDir <> $aSubkey[0] Then $sReleaseDir = $aSubkey[0] EndIf EndIf EndIf EndIf EndIf WEnd If FileExists($sBetaDir) Then ShellExecute($sBetaDir) ElseIf FileExists($sReleaseDir) Then ShellExecute($sReleaseDir) Else MsgBox(48, "Not found", "Plugin not found") EndIf youtuber 1
youtuber Posted March 14, 2021 Author Posted March 14, 2021 (edited) @Subz The code you recently sent is,No problem in Windows 10 tested ok. But in windows 7 it gives an error message "Plugin not found", interesting situation I don't know why Edit: The problem seems to be pattern RegExp Edited March 14, 2021 by youtuber
Subz Posted March 14, 2021 Posted March 14, 2021 Can you post the output of $aSubkey[0] and $aSubkey[1] using the following code within the loop: This will check that there are no spaces in the directory or filename. ConsoleWrite("x" & $aSubkey[0] & "x" & @CRLF & "x" & $aSubkey[1] & "x" & @CRLF) youtuber 1
youtuber Posted March 14, 2021 Author Posted March 14, 2021 xC:\Users\USER\Desktop\Program\GeneralPurposeAppz\Beta\x xmy.exex xC:\Users\USER\Desktop\Program\GeneralPurposeAppz\Release\x xmy.exex or https://prnt.sc/10lqekb
Subz Posted March 14, 2021 Posted March 14, 2021 If FileExists($aSubkey[1]) Then ;~ Should be If FileExists($aSubkey[0] & $aSubkey[1]) Then youtuber 1
youtuber Posted March 14, 2021 Author Posted March 14, 2021 @Subz Thank you, Win10 and Win7 tested,okay.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now