Shortened filenames in shell\...\command subkey

  • Thread starter Thread starter Michael A. Covington
  • Start date Start date
M

Michael A. Covington

I'm trying to rig a way to run LaTeX on a .tex file when the user
right-clicks and chooses it. So far, I have the following subkey defined:

....\shell\LaTeX\command
cmd.exe /c latex "%1" && pause

The problem is, the argument file names are getting shortened (made
DOS-compatible). This doesn't keep LaTeX from opening the right file, but
it does keep LaTeX from generating the right (un-shortened) file names on
the files that it outputs.

If I change the command to:

latex "%1"

(without involving cmd.exe), the same thing occurs.

The following works properly:

"c:\texmf\miktex\bin\latex.exe" "%1"

However, it doesn't give me a way to pause after running LaTeX, so it's not
entirely satisfactory.

What determines whether filenames get shortened when executing the
shell\...\command subkey?
 
This one is so weird that I am documenting it here, for the sake of
posterity.

In a command subkey, apparently,

argument filenames are shortened (made DOS-compatible) if you don't give the
full path for the initial command.

Thus

cmd.exe /c latex "%1" && pause

shortens the filename in %1, but

c:\windows\system32\cmd.exe /c latex "%1" && pause

does not.

Now then. Some machines use c:\windows and some use c:\winnt, so I don't
want to hard-code the path.

But I can't use %SystemRoot% or %windir% in a command subkey (even though
%ProgramFiles% is OK -- go figure!).

My solution was to write an .inf file rather than a .reg file. In .inf
files there's a variable (I seem to recall it's %11%) which is c:\windows or
c:\winnt as appropriate.
 
This one is so weird that I am documenting it here, for the sake of
posterity.

In a command subkey, apparently,

argument filenames are shortened (made DOS-compatible) if you don't give the
full path for the initial command.

Thus

cmd.exe /c latex "%1" && pause

shortens the filename in %1, but

c:\windows\system32\cmd.exe /c latex "%1" && pause

does not.

Now then. Some machines use c:\windows and some use c:\winnt, so I don't
want to hard-code the path.

But I can't use %SystemRoot% or %windir% in a command subkey (even though
%ProgramFiles% is OK -- go figure!).

My solution was to write an .inf file rather than a .reg file. In .inf
files there's a variable (I seem to recall it's %11%) which is c:\windows or
c:\winnt as appropriate.
 
But I can't use %SystemRoot% or %windir% in a command subkey (even though
%ProgramFiles% is OK -- go figure!).

On further scrutiny I find that environment variables are OK in keys of type
REG_EXPAND_SZ (expandable string) but not REG_SZ (string).

If I had known that earlier I might have been spared an exciting
adventure...
 
But I can't use %SystemRoot% or %windir% in a command subkey (even though
%ProgramFiles% is OK -- go figure!).

On further scrutiny I find that environment variables are OK in keys of type
REG_EXPAND_SZ (expandable string) but not REG_SZ (string).

If I had known that earlier I might have been spared an exciting
adventure...
 
Back
Top