Jump to content

@comspec


Recommended Posts

If the "file association" method will not open the file of interest in the app that you want, then how about passing the file to the app on the cmd line?

Run(@ComSpec & " /c C:\WINDOWS\NOTEPAD.EXE C:\Temp\sample.txt", "", @SW_HIDE)

...or perhaps I do not understand what you are attempting...

<{POST_SNAPBACK}>

"and for the record", I suggested passing the file to the app... albiet in what seems to be a strange way, that of using comspec. When cameronsdad's suggestion to just use Run was ignored, I figured that there had to be a reason and I stuck with comspec.

Now I have a question for cameronsdad, "If you pass the full path of the file to the app, is there any advantage to specifying the "workingdir"?

Run("C:\WINDOWS\NOTEPAD.EXE C:\Temp\sample.txt", "", @SW_HIDE)

One possible reason just came to me - some apps generate temp files in the working directory instead of using the temp directory. Those files could show up in undesired places and remain if abnormal termination. Other reasons?

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

"and for the record", I suggested passing the file to the app... albiet in what seems to be a strange way, that of using comspec. When cameronsdad's suggestion to just use Run was ignored, I figured that there had to be a reason and I stuck with comspec.

Now I have a question for cameronsdad, "If you pass the full path of the file to the app, is there any advantage to specifying the "workingdir"?

Run("C:\WINDOWS\NOTEPAD.EXE C:\Temp\sample.txt", "", @SW_HIDE)

One possible reason just came to me - some apps generate temp files in the working directory instead of using the temp directory. Those files could show up in undesired places and remain if abnormal termination. Other reasons?

<{POST_SNAPBACK}>

That is a good reason, i've also seen a few programs that only work with the running directory specified although i can't think of the names of any of them right now. Probably the best reason is just good form and consistency, it never hurts to specify optional parameters, and they help reduce runtime errors. In all honesty i rarely specify optional parameters myself unless i have an issue when running the script, but that's just because i'm lazy...
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...