• 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

    • It depends on how technical of an answer you want. Does it stop manufacture drivers? Yes, the universal driver is the only thing that interfaces with the printer hardware. However, print support apps (PSAs) are the new way to provide that functionality you speak of. They integrate directly into the print dialog box just like the older model, so the user doesn't see any difference at all*. This is nothing new...this has been the preferred way to do print drivers for almost 8 years! The only thing changing here is that the older printer model drivers of the past are being deprecated. I highly suspect that you yourself have installed a print support app described as a driver package from the manufacture's support page, had it work exactly as expected, without realizing it was using the universal IPP driver under the covers. For example, USB keyboards have all used the generic HID driver for just about as long as they have existed, but that doesn't stop manufacture "drivers" from enabling more features. *bit of a disclaimer: the PSA process doesn't require the user to see anything different, but in many cases the manufacture v1.0 PSA "drivers" were pretty basic and lacked the polish of their older V4 print model driver brothers.
    • https://www.neowin.net/news/microsofts-captionbot-will-try-to-caption-any-picture---as-long-as-hitlers-not-in-it/ The early days of "AI"!
    • Wow..... 1.8GB of RAM usage. That's just a bit more than MS Teams or VS Code uses.
    • its slower than ever. especially on mobile ios. really poor app. Slack is a million times better. shame the company i work for moved from Slack to teams few years back. was like moving from 2026 to windows ME.
  • Recent Achievements

    • One Month Later
      Sopa flores earned a badge
      One Month Later
    • First Post
      StaticMatrix earned a badge
      First Post
    • Week One Done
      StaticMatrix earned a badge
      Week One Done
    • Rookie
      lamborghiniv10 went up a rank
      Rookie
    • One Month Later
      pinnclepd earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      531
    2. 2
      PsYcHoKiLLa
      209
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      98
    5. 5
      ATLien_0
      82
  • Tell a friend

    Love Neowin? Tell a friend!