简体   繁体   English

Process.Start(“ IExplore.exe”,“ http://google.com”)未在VM上启动。 在服务器和本地上工作

[英]Process.Start(“IExplore.exe”, “http://google.com”) Not Launching On VM. Works on Server and Local

As Above in Title 如上标题

Process.Start("IExplore.exe", "http://google.com") 

Does not launch IE on a VM I am using. 无法在我正在使用的VM上启动IE。 However Executing on a server real machine and local machine it launches correctly. 但是,在服务器真实计算机和本地计算机上执行时,它将正确启动。

Tried the following: 尝试了以下内容:

Process.Start("IEXPLORE.EXE", "-nomerge http://google.com/");

as suggested in post Process.Start("IEXPLORE.EXE") immediately fires the Exited event after launch.. why? 如Post Process.Start(“ IEXPLORE.EXE”)中建议的那样,启动后立即触发Exited事件。为什么?

and

try
 {
     Process.Start("http://google.com");
 }
catch (System.ComponentModel.Win32Exception)
 {
     Process.Start("IExplore.exe", "http://google.com");
 }

and

ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");

Any suggestions greatly appreciated 任何建议,不胜感激

You got IE installed on the VM right :D? 您在VM上正确安装了IE:D? Anyway try running the app as administrator mayby the UAC settings are "wrong" on the VM. 无论如何,尝试以管理员身份运行该应用程序可能是因为VM上的UAC设置“错误”。

Try this... 尝试这个...

Process.Start("http://www.google.com");

It will launch the site with your default browser. 它将使用您的默认浏览器启动该网站。 Assuming that's Internet Explorer, you're good to go. 假设这是Internet Explorer,那就很好了。

Here is a stripped down class that you might find useful if you want to do IE automation. 这是一个精简的类,如果您想进行IE自动化,可能会很有用。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using SHDocVw;
using mshtml;

public class InternetExplorerInstance
{
   public InternetExplorer Instance;

   public static InternetExplorerInstance GetCurrentInternetExplorerInstance()
   {
      InternetExplorer currentInternetExplorer = CurrentInternetExplorer();
      if ( currentInternetExplorer != null )
      {
         return new InternetExplorerInstance( currentInternetExplorer );
      }
      return null;
   }

   private InternetExplorerInstance( InternetExplorer ie )
   {
      Instance = ie;
   }

   public static void Iterate()
   {
      GetInternetExplorers();
   }

   private static IEnumerable<InternetExplorer> GetInternetExplorers()
   {
      ShellWindows shellWindows = new ShellWindowsClass();
      List<InternetExplorer> allExplorers = shellWindows.Cast<InternetExplorer>().ToList();
      IEnumerable<InternetExplorer> internetExplorers = allExplorers.Where( ie => Path.GetFileNameWithoutExtension( ie.FullName ).ToLower() == "iexplore" );
      return internetExplorers;
   }

   public static void LaunchNewPage( string url )
   {
      InternetExplorer internetExplorer = GetInternetExplorers().FirstOrDefault();
      if ( internetExplorer != null )
      {
         internetExplorer.Navigate2( url, 0x800 );
         WindowsApi.BringWindowToFront( (IntPtr) internetExplorer.HWND );
      }
      else
      {
         internetExplorer = new InternetExplorer();
         internetExplorer.Visible = true;
         internetExplorer.Navigate2( url );
         WindowsApi.BringWindowToFront((IntPtr) internetExplorer.HWND);
      }

   }
}

Not all code is included, but it should be enough for a start. 并非所有代码都包括在内,但对于开始来说应该足够了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 的Process.Start(“IEXPLORE.EXE”); &lt; - 这可靠吗? - Process.Start(“IExplore.exe”); <— Is this reliable? Process.Start("IExplore.exe"); --&gt; System.IO.FileNotFoundException - Process.Start("IExplore.exe"); --> System.IO.FileNotFoundException Process.Start(“IEXPLORE.EXE”)在启动后立即触发退出事件..为什么? - Process.Start(“IEXPLORE.EXE”) immediately fires the Exited event after launch.. why? c#:是否可以将参数挂接到现有进程。 启动iexplore.exe,然后使其导航到网站的示例 - c# : is it possible to hook arguments to an existing process. Example launching iexplore.exe and then making it to navigate to a website Process.Kill似乎不适用于iexplore.exe - Process.Kill does not seem to work with iexplore.exe 使用Process.Start启动文件有效,但添加条件无效 - Launching a file using Process.Start works, but adding conditions does not 使用Process.Start作为本地管理员帐户启动单独的程序 - Launching separate program as a local admin account using Process.Start IEXPLORE.exe的奇怪的ProcessorAffinity问题 - Strange ProcessorAffinity issue with IEXPLORE.exe Process.Start()没有启动.exe文件(手动运行时有效) - Process.Start() not starting the .exe file (works when run manually) C#在子文件夹中使用Process.Start for exe在与启动exe相同的文件夹中启动 - C# using Process.Start for exe in a sub folder launches in same folder as launching exe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM