#11 2011-11-20 14:58

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: MSI files are detected as ppt/xls/doc files

narayan wrote:

Currently the dll and trd files are in the top-level folder of ReNamer (where the renamer.exe file is.)
Should I move them to a subfolder?

That's where I have them, and it works (v5).

I can't help any more here.

Anyway, I think MSI is a popular enough extension to be considered. And being almost like the only real alternative to an EXE looks important to me.


If this software has helped you, consider getting your pro version. :)

Offline

#12 2011-11-21 19:02

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: MSI files are detected as ppt/xls/doc files

narayan wrote:

Hi Andrew,

I cannot find this TrID pas either in the menu or in the folder. Where is it?

Hi narayan,

I linked the second image (which displayed the script's results) directly to the latest version of the script, but guess I was too smart for my own good, and it wasn't obvious at all that there was a link there! roll

narayan wrote:

But now Stefan has pointed to your script posted at forum.
Your version was written a month later; and has some improvements.
Could you please update the wiki page with the new script?
I could have done a simple "copy and paste" in the wiki, but you would be a better judge about what needs to be done.

Do I replace the existing script on that page (Denis' initial version) with v5 of the script, or append it, or what? The Wiki's more your domain, so I leave it in your capable hands. smile A simple copy-paste is what I'll do as well in any case, since I can't really think of anything else to include right now.

As far as running the script goes, all you need to do is save it as a .PAS file in the Scripts sub-folder, and place the 2 required files (.DLL and .TRD) in the top-level folder (alongside ReNamer's EXE, tested with the latest Beta). After that, add a few files to the list, add the script as a rule, Preview and the script should work! Seems to work fine for SafetyCar as well, so you might be missing out on some minor detail somewhere that's causing an issue.

hhq10qhcb9rdds8c2yvq.png

P.S. If you continue to face issues, make sure the script compiles successfully, and then try once more.

Last edited by Andrew (2011-11-21 19:04)

Offline

#13 2011-11-22 10:28

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: MSI files are detected as ppt/xls/doc files

Hi Andrew,

Thanks, I will update the wiki with v5.

****
Denis,

I have found a pattern for this bug:

First let me describe the common setup: I have saved Andrew's version of the script (v5) as  "ExtensionFinder.pas" file in the Scripts folder.
I also copied the TRID dll and trd files in the main folder.

Given this, the success or failure of extension-finding depends on the method I follow (I checked by repeating the experiments):

1. The following method is successful:
Launch ReNamer by double-clicking on the executable.
Add the test file.
Add the Pascalscript rule.
Click on "Scripts" button. From the script's list that pops up, select the ExtentionFinder script.
Click on the "Try to compile!" button. A "Compiled successfully!" message appears.
Press on "Add rule". The files pane shows the new extension.

2. The following method fails:
Select the file to be renamed from explorer.
Launch ReNamer using the keyboard shortcut I have set. The file is loaded in the "Files" section.
Add the "Pascalscript" rule.
Click on "Scripts" button. From the script's list that pops up, select the "ExtentionFinder" script.
Click on the "Try to compile!" button. A "Compiled successfully!" message appears.
Press on "Add rule". At this moment, the following error message pops up:

---------------------------
Confirm
---------------------------
Error! TrIDLib.dll and/or TrIDDefs.trd not found in the program directory!

Do you want to download the latest versions from the TrID website now?
---------------------------
Yes   No   
---------------------------

3. A variation of the case-2 above also fails:

Launch the ReNamer by selecting a file and pressing the keyboard shortcut.
ReNamer launches and shows the file in the "Files" pane.
Delete the file from the "Files" pane.

At this moment, the ReNamer's state (in theory) should be same as case-1 above (but it is NOT, as shown below).

Add the "Pascalscript" rule.
Click on "Scripts" button. From the script's list that pops up, select the "ExtentionFinder" script.
Click on the "Try to compile!" button. A "Compiled successfully!" message appears.
Press "Add Rule" button. There is no error so far.
Now drag-n-drop the test file in the "Files" pane.

Immediately the same error message pops up (see above).

********
Conclusion: Launching ReNamer with a file as argument seems to trigger the problem.

Offline

#14 2011-11-23 18:08

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: MSI files are detected as ppt/xls/doc files

DLL must be in the search path.

The search path also depends on how you launch ReNamer. In your examples the current directory may differ.

Windows searches for the DLLs in the following sequence:

  1. The directory where the executable module for the current process is located.

  2. The current directory.

  3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

  4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

  5. The directories listed in the PATH environment variable.

If you are going to post Andrew's script on the wiki, please add it to the article, don't replace the old code.

P.S. Sorry guys, I don't have any free time these days.

Offline

#15 2011-11-23 19:10

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: MSI files are detected as ppt/xls/doc files

Hi Andrew,

The problem may be there only in case of the extension-finder script, because the other Pascal scripts do not use external files.
Can you please take care of this, so that ReNamer can handle all three types of launches I described?

Thanks in advance!

Offline

#16 2011-11-24 06:55

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: MSI files are detected as ppt/xls/doc files

narayan wrote:

Can you please take care of this, so that ReNamer can handle all three types of launches I described?

I can try, but I need your help. First, tell me how exactly you're launching ReNamer from within Win Explorer with the selected files loaded. What's this keyboard shortcut and how is it configured?

Second, test the following modified script and see if it works (launch ReNamer using that shortcut of yours and test from various locations/paths). If it fails, tell me what is reported in the error dialog as being the program's path.

[Script deleted, see next page for latest version.]

-----

den4b wrote:

DLL must be in the search path.

The search path also depends on how you launch ReNamer. In your examples the current directory may differ.

Windows searches for the DLLs in the following sequence:

  1. The directory where the executable module for the current process is located.

    ...

Denis, shouldn't the very first option match, since irrespective of the program's CWD (depends on how the shortcut is configured), the dir. for the executable module i.e. ReNamer.exe shouldn't change, right? So why is it failing to locate the files?

Last edited by Andrew (2011-11-26 11:29)

Offline

#17 2011-11-24 11:03

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: MSI files are detected as ppt/xls/doc files

First, I will describe the set up:

I use xplorer2; a dual-pane shareware that replaces Windows Explorer.

The keyboard shortcut is associated with the following command:
>"C:\Program Files\Util\ReNamerBeta\ReNamer.exe" $A

Where > launches a windows command; and the $A token represents the selected items (files/folders) as argument.

Shortcut:
On my work PC (Win 7) it is is CTRL+ALT+0.
On my home PC with Win XP SP-3, it is CTRL+SHFT+0.
**********
The above shortcut works fine in launching ReNamer with any Preset (with ANY combination of rules), or any other Pascal script.
The extension-finder script is the only script that does NOT work.

**********
I tried v6, but it has the same issue with Test Case-2 (from now, I will refer to it as "TC2" in short).
But in addition, ReNamer also creates a new 0-byte file called "TrIDDefs.TRD" in the folder where the file-to-be-renamed is located.
(v5 did not do this).

V6 also fails with TC3. Again, ReNamer creates a new 0-byte file called "TrIDDefs.TRD" in the target file's folder.

v6 works well with TC1 (but then so did the v5).

Offline

#18 2011-11-24 11:12

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: MSI files are detected as ppt/xls/doc files

Test Case-4:

I created a shortcut of ReNamer executable in the Send to folder.
Then I right-clicked on the target file, and from the context menu that appears, selected the "Send to ReNamer" option.
The ReNamer got launched with the target file loaded in its "folder" pane.
Now I add the Pascal Script rule, and select the Extension-finder script.

This method works just fine with V6.

Offline

#19 2011-11-24 12:51

narayan
Senior Member
Registered: 2009-02-08
Posts: 470

Re: MSI files are detected as ppt/xls/doc files

Another experiment: I added the path of the Renamer's folder to the PATH variable. This did not change the result.

BTW it is strange that the error message expects the trd and dll files to be there in the target file's folder, and not in the ReNamer executable's folder.

For example, for my work PC:
The ReNamer executable is here: C:\Program Files\Util\ReNamerBeta
And the target file is here: D:\Data\Downloads

And the error message says:

---------------------------
Confirm
---------------------------
Error! TrIDLib.dll and/or TrIDDefs.trd not found in the program directory (D:\Data\Downloads)!

Do you want to download the latest versions from the TrID website now?
---------------------------
Yes   No   
---------------------------


While ReNamer states "not found in the program directory", it actually shows the path of the target file!
In other words, either the error message is composed with wrong path, or the script is looking for the files in the wrong folder.

Offline

#20 2011-11-24 16:48

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: MSI files are detected as ppt/xls/doc files

Yes, the issue is one of an incorrect working directory being set when you call ReNamer via your shortcuts. The same can be replicated if you create a shortcut to ReNamer.exe (or copy the EXE and paste as shortcut, which is quicker). Say the EXE resides in C:\Program Files\ReNamer, and the shortcut is placed in E:\Utils. If you right-click the shortcut and set the "Start in" field to E:\Utils (or leave it blank), the program's curent working dir. as reported by the script will of course be E:\Utils. This is what is also happening when you call the EXE via your shortcuts. Can you test something else for me? In v6 of the script, just replace the following lines:

if (not Initialized) then
  begin
    if (not WideFileExists(WideGetCurrentDir()+'\TrIDLib.dll')) Or (WideFileSize(WideGetCurrentDir()+'\TrIDLib.dll')=0)
    Or (not WideFileExists(WideGetCurrentDir()+'\TrIDDefs.trd')) Or (WideFileSize(WideGetCurrentDir()+'\TrIDDefs.trd')=0) then
    begin
      if (DialogYesNo('Error! TrIDLib.dll and/or TrIDDefs.trd not found in the program directory (' + WideGetCurrentDir() + ')!'
      + #13#10#13#10 + 'Do you want to download the latest versions from the TrID website now?')) then
        ShellOpenFile('http://mark0.net/soft-trid-e.html');
      FileErr := True;
    end;
    TridLoadDefsPack('');
    Initialized := True;
  end;
  if (FileErr) then Exit;
  TridSubmitFileA(PChar(FilePath));

with these:

if (not Initialized) then
  begin
    TridLoadDefsPack('');
    Initialized := True;
  end;
  TridSubmitFileA(PChar(FilePath));

This removes the check for the 2 files, and will cause the script to simply not work and silently fail if either of the files is missing. Just see if this modified script works without a problem in all 4 cases. If it does, then hopefully Denis can create a new WideGetProgramDir() method for us to use, which will always return the full path to the ReNamer EXE, wherever it's been launched from.

Last edited by Andrew (2011-11-24 16:50)

Offline

Board footer

Powered by FluxBB