• 0

[C#] Process.Start with current path?


Question

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:


[ComVisible(true)]
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
[/CODE]

I then launch a program like this:

[CODE]
[ComVisible(true)]
public void LaunchPlayer()
{
Process.Start("wmplayer.exe", "ANYFOLDER");
}
[/CODE]

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?

Link to comment
https://www.neowin.net/forum/topic/1122150-c-processstart-with-current-path/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

My JavaScript sends a selected path, for example C:\files to com ActiveX, I catch it on C# like this:


[ComVisible(true)]
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
[/CODE]

I then launch a program like this:

[CODE]
[ComVisible(true)]
public void LaunchPlayer()
{
Process.Start("wmplayer.exe", "ANYFOLDER");
}
[/CODE]

The problem is that how do I launch the program so that it uses the current value on myparam on "anyfolder"?

Wicked. Do people still use ActiveX? I have no experience in that what so ever. Have you tried Stackoverflow?

  • 0

public void LaunchPlayer()
{
System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo();
PSI.FileName = "wmplayer.exe";
PSI.WorkingDirectory = "C:\\MyDirectory";
System.Diagnostics.Process.Start(PSI);
}
[/CODE]

  • 0

Unless I understood the OP's question incorrectly, this should do the trick:

Process.Start("wmplayer.exe", myParam);[/CODE]

The second parameter specifies the arguments passed to the executable. If you want to launch the executable with a different working directory, you should follow stumper66's suggestion above and set the WorkingDirectory property accordingly.

  • 0

Is there anything better that I can use? I use ActiveX so that I can send parameters from javascript to methods in .dll.

From the way you are using it, doubt there is another way other than COM (am I wrong to assume you are actually using COM and not ActiveX which is a variant of COM/OLE and used primarily for shared UI controls?)
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • After watching the Apple event earlier this week it is quite the contrast. Apple is going back and tweaking the code to make things more efficient in many areas of MacOS. Windows is boosting your electric build to hide their issues.
    • It is silly there is no simple way to check whether this profile has been activated. CFRs are normal, but trying to even hide the fact if it's on / off seems silly, especially for something so user-facing. Surely Microsoft is "proud" of their engineering efforts on this one and ought to display it somwhere in the GUI.
    • Many Linux distros are not known for excellent battery life, so I'm not sure that is the best example. A more apt example may be Apple, but Apple's CPUs are simply far more efficient than Intel & AMD at single-threaded tasks like these, so "boosting" is not as power-hungry and less heat-inducing. Not to mention Apple will hardly engage P-cores for basic UI tasks; they use a pretty complicated QoS scheme to only activate P-cores for more serious workloads like HTML / JS execution or decompression or application launch. Microsoft is (smartly) doing it for launch, but also for UI tasks, which is the more nonsensical part: why ... do Windows 11's UIs need modern CPUs to boost? It should load so quickly that there's not even time for the CPU to boost.
    • I've not seen any controlled testing and, judging by Microsoft's mentality, within a year, they'll have added so much more bloat, it'll undo any perceptible latency benefit and we'll have boosted the CPU clocks for nothing.
    • It depends: heat soak is a thing. Initially on cold boot-up, the heatsinks & heatpipes are at ambient temp. After heatsinks & heatpipes warm up (through normal usage), they don't immediately cool to ambient temp when the load goes away. So their baseline is higher and the trigger point for fans is much less stress. Add a few more CPU spikes → it's too hot to stay at the same fan RPM → fans get triggered to start up up much sooner / get triggered to ramp much more quickly.
  • Recent Achievements

    • One Year In
      slackerzz earned a badge
      One Year In
    • One Year In
      highriskpaym earned a badge
      One Year In
    • One Month Later
      highriskpaym earned a badge
      One Month Later
    • Week One Done
      highriskpaym earned a badge
      Week One Done
    • Week One Done
      FBSPL earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      500
    2. 2
      PsYcHoKiLLa
      198
    3. 3
      +Edouard
      157
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      74
  • Tell a friend

    Love Neowin? Tell a friend!