C# getMainModule上出现意外的Win32异常

C# getMainModule上出现意外的Win32异常,c#,.net,jar,process,permissions,C#,.net,Jar,Process,Permissions,我有下面的代码 string currentDir = Directory.GetCurrentDirectory(); Process mcProcess = new Process(); mcProcess.StartInfo.WorkingDirectory = currentDir; //mcProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; mcProcess.StartInfo.

我有下面的代码

    string currentDir = Directory.GetCurrentDirectory();
    Process mcProcess = new Process();
    mcProcess.StartInfo.WorkingDirectory = currentDir;
    //mcProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    mcProcess.StartInfo.UseShellExecute = true;
    mcProcess.StartInfo.FileName = "java.exe";
    mcProcess.StartInfo.Arguments = @"-jar Minecraft\forge.jar -Xms2G -Xmx2G";
    //mcProcess.StartInfo.RedirectStandardOutput = true;
    mcProcess.Start();
    //MetroMessageBox.Show(this, mcProcess.StandardOutput.ReadToEnd());
    //mcProcess.WaitForExit();
这会在进程启动时引发Win32Exception,我已经检查了目标体系结构,它是x64。Java路径设置正确,如果我在控制台上运行该命令,它可以正常工作。然而,这是行不通的

消息:readprocessmemory或writeprocessmemory请求仅完成了一部分(已翻译,因此可能不是100%准确)

堆栈跟踪:

'mcProcess.MainModule' threw an exception of type 'System.ComponentModel.Win32Exception'
   at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
   at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
   at System.Diagnostics.Process.get_MainModule()
本机错误代码为299 AKA error\u OPLOCK\u NOT\u

编辑:这似乎是一个权限问题,因为以管理员的身份运行编译后的可执行文件很好。
如何使其适用于非提升用户?

正如预期的那样,这是一个权限问题

我解决这个问题的方法是从注册表中获取JAVA_HOME变量,并在其中附加“\bin\JAVA.exe”以获取完整路径