用管理员登陆PC之后,能否实现指定用户执行外部程序?

解决方案 »

  1.   

    又是一个看不大懂的问题。如果要开机启动,可以直接从HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run或HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run里面进行设置;如果是从一个C#程序中调用另一个exe(外部程序),可以用平台调用的方式调用CreateProcess。
      

  2.   

    我知道CreateProcess 以当前用户身份调用外部程序,我要以其他用户身份调用外部程序,又如何做到呢?
      

  3.   

    就是说你当前用户是administrator
    而你想用windows 其它用户的方式执行程序?
      

  4.   

    这次了解了你的意图了。可以试一下“CreateProcessWithLogonW”或者CreateProcessAsUser函数。(还是要记住用平台调用)
    因为我的Windows系统和MSDN都是英文的,所以只贴个英文的帮助信息了。The CreateProcessWithLogonW function creates a new process and its primary thread. The new process then runs the specified executable file in the security context of the specified credentials (user, domain, and password). It can optionally load the user profile for the specified user.The CreateProcessWithLogonW function is similar to the CreateProcessAsUser function, except that the caller does not need to call the LogonUser function to authenticate the user and get a token.