Windows 10/Administration/users

Windows 10/Administration/users

Run program as other users

在资源管理器里按住 Shift 右击可执行文件,选择 "Run as another user",然后输入用户名和密码。如果需要以 administrator 身份执行可以直接右击可执行文件,选择 "run as administrator"(强烈推荐彻底关闭 UAC 使所有程序默认以 administrator 权限执行)。

CMD:

runas /user:username "cmd.exe /C mycommand"

但通过 CMD 的 runas 仍然会要求输入对应用户的密码,无法通过命令行参数传入密码。傻逼微软!。如果需要通过命令行传入密码,可以使用微软自己做的 PSTools 软件里的 PsExec.exe 命令行工具:

PsExec -accepteula -d -user user -p "123456" "cmd"

PsExec 参数:

  • -d : Don't wait for process to terminate (non-interactive).
  • -accepteula : This flag suppresses the display of the license dialog.

示例:以其他(非管理员)身份启动 qq

安装 qq 绿色版(直接解压即可使用。测试 QQ-v7.9L.14308-portable 可用)。在系统里创建一个 users 用户组的普通用户专门用来运行 QQ: compmgmt.msc - Local users and groups - Users - Context Menu: New User。

qq/
|--- bin/QQ.exe
|---- start-qq-as-user.bat

start-qq-as-user.bat

setlocal
cd /d %~dp0
cd BIN
PsExec -accepteula -d -user user -p "123456" "QQ.exe"

rename username (id)

Computer Management - users, rename user

Login as another administrator user, rename user profile C:\users\user to C:\users\newuser

regedit, and modify the registry value ProfileImagePath to the new path name.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\<User SID>\

A note on : the ProfileList registry key contains a number of sub-keys. To find out which one to change, click on each sub-key and examine the values, to find the sub-key with the right ProfileImagePath

修改用户密码

net user username password

Last update: 2021-04-26 06:58:17 UTC