How to get current user name from process started using RunAs command with diffrent profile.

M

Marek Suski

Hi all

How to get current user name (name of the user that logged on) from process that was started using "RunAs" command?

For example

User "MarkSmith" has started a VB application using RunAs command where user name was "Admin". Now VB app needs to copy some file to MarkSmith application data folder (C:\Documents and Settings\marksmith\Application Data\). I need to know how to get user name to do that. If I use %username% or WshMetwork.UserName I am getting "Admin" instead "MarkSmith".

Maybe I could read user name from registry?

Thank you for your help

Marek Suski
 
M

Matt Gibson

No way. You're effectively running that program AS Admin, so all the
username variables will point to Admin. You might be able to hack SOMETHING
up that queries something else...like what username started Explorer.exe or
something to that effect.

Matt Gibson - GSEC
Hi all
How to get current user name (name of the user that logged on) from process
that was started using "RunAs" command?
For example
User "MarkSmith" has started a VB application using RunAs command where user
name was "Admin". Now VB app needs to copy some file to MarkSmith
application data folder (C:\Documents and Settings\marksmith\Application
Data\). I need to know how to get user name to do that. If I use %username%
or WshMetwork.UserName I am getting "Admin" instead "MarkSmith".
Maybe I could read user name from registry?
Thank you for your help
Marek Suski
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top