4

I am by no means a PowerShell expert; I have spent a good while googling this, but haven't found an answer.

The basic idea of my script is to run a Microsoft tool called appcert.exe with command-line arguments. appcert.exe returns 0, 1, or -1; I am checking it with $lastexitcode.

appcert.exe only runs on Windows 7 and Windows 8, so I have run my script on both.

Everything works fine on Windows 7x64 (PS version = 2.0). I can manually run all the same steps. I see the output of appcert.exe in the same PS window.

Different story on Windows 8x64 (RTM), where PS version = 3.0, CLRVersion = 4.0.30319.17929.

Sometimes, appcert.exe runs "inline" (like it did in Win7); other times, a command window is launched, the appcert.exe output flies by, and command window closes. The PS window that called it can't check $lastexitcode (which, by the way, is not set at all).

I tried all PS versions on machine, and results are as follows:

  1. appcert.exe is launched in separate window in these instances:

    • In PowerGUI 3.2.0.2237 (uses PS 2.0)
    • In regular PowerShell (non-admin)
    • In Windows PowerShell ISE (non-admin)
  2. appcert.exe is launched inline in these instances:

    • Ran Powershell as administrator
    • Ran ISE as administrator

Behavior above is obtained whether I:

  1. Launch script, which calls the appcert command like this: & $CertToolPath
  2. cd to the home direcotry of the tool and type .\appcert.exe
  3. Run this: Cmd /c appcert.exe
  4. Run this: Invoke-expression –command appcert.exe
  5. Run this: [system.diagnostics.process]::start("appcert.exe")

My colleagues are equally stumped by this.

My machine is in a test domain, not a workgroup. I log into the machine as an admin of the test domain, so theoretically, I'm already an admin.

I install the MS tool as that admin, too. In fact, I never do anything as the machine's local admin. Any ideas? :)

Many thanks in advance, Tania

4

1 回答 1

1

你能用任何其他exe重现这个吗?您是否禁用了 UAC 提示?

appcert.exe 是否可能需要以管理员身份运行,如果没有,它会自动以管理员身份重新启动(这应该会导致 UAC 提示,但如果您将它们关闭,它似乎只是产生一个新实例自动)?

于 2012-12-10T18:40:33.797 回答