shaf2150 Posted May 9, 2005 Share Posted May 9, 2005 I am trying to create a button that will automatically open a text file (.doc, .txt) with the correct program. I have read the helpfile and the FAQ. Most of the files are located on a mapped network drive, but the word processor is located on the local machine. What do I need to include in the run command? Link to comment Share on other sites More sharing options...
w0uter Posted May 9, 2005 Share Posted May 9, 2005 (edited) I am trying to create a button that will automatically open a text file (.doc, .txt) with the correct program. I have read the helpfile and the FAQ. Most of the files are located on a mapped network drive, but the word processor is located on the local machine. What do I need to include in the run command?<{POST_SNAPBACK}>im not sure what your trying to do but i think ur trying to shellexecute. if so you could try this:YOU NEED AUTOIT++ (3.1.1.xx ) for this script to work$oShell = ObjCreate("shell.application") $oShell.Open("path\to\file.doc") Edited May 9, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 9, 2005 Share Posted May 9, 2005 I am trying to create a button that will automatically open a text file (.doc, .txt) with the correct program. I have read the helpfile and the FAQ. Most of the files are located on a mapped network drive, but the word processor is located on the local machine. What do I need to include in the run command?<{POST_SNAPBACK}>Well, windows 2k/XP comes with a wonderful shell command called "start" that will attempt to run a file in the native, assoiciated program.expandcollapse popupMicrosoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. 05/09/2005 15:29:51.96 C:\>start /? Starts a separate window to run a specified program or command. START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/WAIT] [/B] [command/program] [parameters] "title" Title to display in window title bar. path Starting directory B Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application I The new environment will be the original environment passed to the cmd.exe and not the current environment. MIN Start window minimized MAX Start window maximized SEPARATE Start 16-bit Windows program in separate memory space SHARED Start 16-bit Windows program in shared memory space LOW Start application in the IDLE priority class NORMAL Start application in the NORMAL priority class HIGH Start application in the HIGH priority class REALTIME Start application in the REALTIME priority class ABOVENORMAL Start application in the ABOVENORMAL priority class BELOWNORMAL Start application in the BELOWNORMAL priority class WAIT Start application and wait for it to terminate command/program If it is an internal cmd command or a batch file then the command processor is run with the /K switch to cmd.exe. This means that the window will remain after the command has been run. If it is not an internal cmd command or batch file then it is a program and will run as either a windowed application or a console application. parameters These are the parameters passed to the command/program If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows: non-executable files may be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). See the ASSOC and FTYPE commands for how to create these associations from within a command script. When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script. When executing a command line whose first token is the string "CMD " without an extension or path qualifier, then "CMD" is replaced with the value of the COMSPEC variable. This prevents picking up CMD.EXE from the current directory. When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD Notice the syntax is the same as the PATH variable, with semicolons separating the different elements. When searching for an executable, if there is no match on any extension, then looks to see if the name matches a directory name. If it does, the START command launches the Explorer on that path. If done from the command line, it is the equivalent to doing a CD /D to that path. 05/09/2005 15:29:57.76 C:\> Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
w0uter Posted May 9, 2005 Share Posted May 9, 2005 i dislike start. becouse when i used IE. And i used start to open a webpage. It just opend it over my existing site. While COM did not. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 9, 2005 Share Posted May 9, 2005 i dislike start.becouse when i used IE. And i used start to open a webpage. It just opend it over my existing site.While COM did not.<{POST_SNAPBACK}>Meh. We posted at roughly the same time. I didn't realize that you'd had a reply in before me. heh. Yes, start has its shortcomings (as do all MS products), but for text files, it should be just fine. Either way is perfectly valid. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
shaf2150 Posted May 10, 2005 Author Share Posted May 10, 2005 I have a GUI that I created with buttons that point to programs on our network. I now want to create a few buttons that point to Word, Excel and text documents on our network. How do I do that to insure that it opens with the appropriate program? Link to comment Share on other sites More sharing options...
PerryRaptor Posted May 10, 2005 Share Posted May 10, 2005 What happens when you double click on the filenames for each of the programs and documents that are located on the Network? Link to comment Share on other sites More sharing options...
Kerberuz Posted May 10, 2005 Share Posted May 10, 2005 I am trying to create a button that will automatically open a text file (.doc, .txt) with the correct program. I have read the helpfile and the FAQ. Most of the files are located on a mapped network drive, but the word processor is located on the local machine. What do I need to include in the run command?<{POST_SNAPBACK}>I'd use the registry to find out what program the file is assicated to.Here is an example:Say you want to open a *.doc fileTry and open HKEY_CLASSES_ROOT\.doc you will want the (Default) keyNow in my case on my machine the default information is Word.document.8So next you will want to open HKEY_CLASSES_ROOT\Word.document.8\shell\Open\commandWhich will have the path to the program that is associated to the file. Then you can build a string with the files parameter. Kerby Link to comment Share on other sites More sharing options...
shaf2150 Posted May 10, 2005 Author Share Posted May 10, 2005 What happens when you double click on the filenames for each of the programs and documents that are located on the Network?<{POST_SNAPBACK}>Well if I double click on a .doc file Word opens. The file associations are not the problem. I created a GUI with buttons that launch applications stored on our server. I need to know how to launch files that are NOT executables. I will have a button labeled "Windows XP documentation". When a user clicks on that button Microsoft Word will open up that file for the user to read on their machine. I don't know if I am making this harder than what it is or what. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
JSThePatriot Posted May 10, 2005 Share Posted May 10, 2005 You are certainly not making it harder. I will give you an example of how to do it using the above methods when I get home. You have been given several options, but right now I cant really expound on them. Look at the registry one as that will be the cleanest way... also you could look in the Scripts and Scraps forum I know Ezzetabi made a _Run() function that would open any type of file not just an exe. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
shaf2150 Posted May 10, 2005 Author Share Posted May 10, 2005 I took your advice and looked in scripts and scraps and found what I was looking for: Run("cmd /c start H:\AntiVirus.doc", "", @SW_HIDE) Works as advertised. I really appreciate everyones help. Thanks again. Link to comment Share on other sites More sharing options...
scriptkitty Posted May 10, 2005 Share Posted May 10, 2005 (edited) if you are using a few other flavors of windows, you might try this: Run(@comspec & " /c start H:\AntiVirus.doc", "", @SW_HIDE) cmd.exe is for NT based kernals mainly. forgot how many windows versions have start, but I remember WinME having it, and it uses command.com for its secondary comand interpreter. The @comspec uses the correct secondary comand interpreter for the version of windows you run the script on. Edited May 10, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
shaf2150 Posted May 10, 2005 Author Share Posted May 10, 2005 Thanks for the tip Kitty. I messed around with my code and found that this works as well: Run('D:\Program Files\Microsoft Office\Office10\winword.exe "W:\IT_Department\Division\01 - Administration\AutoSpin\Windows XP Auto Install.doc" ') Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 10, 2005 Share Posted May 10, 2005 Thanks for the tip Kitty. I messed around with my code and found that this works as well:Run('D:\Program Files\Microsoft Office\Office10\winword.exe "W:\IT_Department\Division\01 - Administration\AutoSpin\Windows XP Auto Install.doc" ')<{POST_SNAPBACK}>Ok, what if the user has Winword installed on a path other than the one you've specified? That code will fail and will crash your script. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
scriptkitty Posted May 10, 2005 Share Posted May 10, 2005 (edited) true, if you wanted to make sure they used word, you could try: $wordpath=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe","path") Run($wordpath & 'winword.exe "W:\IT_Department\Division\01 - Administration\AutoSpin\Windows XP Auto Install.doc" ') They have advantages and disadvntages, like way you want to have it start minimised. $wordpath=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe","path") Run($wordpath & 'winword.exe "W:\IT_Department\Division\01 - Administration\AutoSpin\Windows XP Auto Install.doc" ',"",@sw_minimize) You could also put a test if winword not found, or have your script look for the default .doc extention handler. start has great uses, but it is just one tool, and knowing when and why to use each tool shows the skill of the programer. Not saying which is best here, just pointing that there are more than one way to skin a cat. Edited May 10, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 11, 2005 Share Posted May 11, 2005 Not saying which is best here, just pointing that there are more than one way to skin a cat.<{POST_SNAPBACK}>Heh, or a scriptkitty. Yeah, I'm not trying to say Start is better than reading the registry for the path, or whatever. I was merely pointing out that assumption of defaults opens up a world of pitfalls. Assume nothing. In God we trust. All others must pay cash at the door Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now