Shell Command

J

Jasper Recto

I have a shell command that looks like this:

Word = Shell("""C:\WINNT\Explorer.EXE"" """ & MyPath & """", 1)

This lauches a word document using explorer.

The problem is that it only works in Windows 2000 because the explorer.exe
is located in the WINNT directory.

If I want it to work for Windows XP, I have to create a new command that
points to the WINDOWS directory.

Is there a way to make this work in both windows 2000 and windows XP
environment with just using one command line?

Thanks,
Jasper
 
K

Keven Denen

I have a shell command that looks like this:

Word = Shell("""C:\WINNT\Explorer.EXE"" """ & MyPath & """", 1)

This lauches a word document using explorer.

The problem is that it only works in Windows 2000 because the explorer.exe
is located in the WINNT directory.

If I want it to work for Windows XP, I have to create a new command that
points to the WINDOWS directory.

Is there a way to make this work in both windows 2000 and windows XP
environment with just using one command line?

Thanks,
Jasper

Use %WINDIR% wherever your would normally put c:\winnt or c:\windows.
It refers to the location windows is installed to.

Keven Denen
 
D

Douglas J. Steele

In VBA, you'd use the Environ function:

Word = Shell("""" & Environ("WinDir") & "\Explorer.EXE"" """ & MyPath &
"""", 1)

Usually, though, %WinDir% is in the path, so

Word = Shell("Explorer.EXE """ & MyPath & """", 1)

should usually be sufficient.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a shell command that looks like this:

Word = Shell("""C:\WINNT\Explorer.EXE"" """ & MyPath & """", 1)

This lauches a word document using explorer.

The problem is that it only works in Windows 2000 because the explorer.exe
is located in the WINNT directory.

If I want it to work for Windows XP, I have to create a new command that
points to the WINDOWS directory.

Is there a way to make this work in both windows 2000 and windows XP
environment with just using one command line?

Thanks,
Jasper

Use %WINDIR% wherever your would normally put c:\winnt or c:\windows.
It refers to the location windows is installed to.

Keven Denen
 

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