Shortened filenames in shell\...\command subkey

  • Thread starter Michael A. Covington
  • 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?
 
M

Michael A. Covington

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.
 
M

Michael A. Covington

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.
 
M

Michael A. Covington

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...
 
M

Michael A. Covington

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top