Jump to content

run command


Recommended Posts

On my Windows XP machine, I can go to the run command and type 'winword' and hit enter, and Word will open. I assume this is because the folder where the executable resides, is in the 'path' variable on the PC.

When I try and run Word using the RUN("winword.exe") command, it doesn't work, but if I use the entire path like Run("c:\program files\microsoft office\office10\winword.exe"), it works just fine.

Is there a way around this? I would like to write a script that will run on any PC that has Word loaded, but I can't guarantee that the executable is in the same location on every PC.

Link to comment
Share on other sites

3 ideas

1 check all known locations

If FileExists(@ProgramFilesDir & "\microsoft office\office10\winword.exe") Then

Run(@ProgramFilesDir & "\microsoft office\office10\winword.exe")

and other known locations

2 Run(@ComSpec & " /C START winword.exe", "", @SW_MINIMIZE) ;or maximized

Sorry forgot the 3rd idea

hope it helps.......

NEWHeader1.png

Link to comment
Share on other sites

If you look at the Default value at the registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe

...you'll get the short path the the Word executable.

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

Command Run(@ComSpec & " /C START  winword.exe", "", @SW_MAXIMIZE) worked

that's because launching a command from cmd.exe just by typing the name, will only search the application in the env variable %path%, while start will also search the registry for the application. As DaveF already posted, this is found in:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...