The requested operation requires elevation

前端 未结 1 1036
無奈伤痛
無奈伤痛 2021-01-12 07:04

I am trying to run an exe file from another user account name, it shows following error

    System.ComponentModel.Win32Exception: The requested operation req         


        
相关标签:
1条回答
  • 2021-01-12 07:28

    Unfortunately, you cannot do

    • run with elevated permissions and
    • redirect input/output

    simultaneously.

    Reason:

    • Verb is only recognized when UseShellExecute = true, but
    • redirecting IO requires UseShellExecute = false.

    More information:

    • Elevating privileges doesn't work with UseShellExecute=false

    I guess in your situation you will have to skip using runas, but rather ensure that your application is already started with the correct user account/permissions. This should work, since processes started by elevated processes "inherit" elevation.

    0 讨论(0)
提交回复
热议问题