[英]Get logged on username in Excel VBA - not the account running Excel (using RunAs)
[英]How to get username of logged-in user when application started with RUNAS
我用一个简短的 RUNAS 脚本来启动 Excel/MS Access:
runas .netonly /user:%id% "C:\Windows\System32\cmd.exe /c START excel.exe /r"
现在我的问题是:如何在 VBA (xls?accdb) 中获取此应用程序 (,) 的登录用户名? 有办法吗?
您可以使用:
RunAs /netonly /user:%id% "C:\Windows\System32\cmd.exe /c START MSACCESS.exe """d:\Path\Your Database Name.accdb""" /cmd %id%"
然后,在 VBA 中,使用Command
读取值:
id = VBA.Command
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.