Need to make a scheduled task run as another user but keep the current user’s environment
Posted
by
Chad Marmon
on Server Fault
See other posts from Server Fault
or by Chad Marmon
Published on 2012-07-09T14:19:33Z
Indexed on
2012/07/09
15:17 UTC
Read the original article
Hit count: 577
I need to backup users .pst files. The current method I am trying is making a shadow copy using Diskshadow. My script works great all but Diskshadow needs to be ran as administrator but also needs to retain the logged-on user's environment variables; specifically, the %USERNAME% and %HOMESHARE% variables so the right user’s files get copied up to the right network location. I have for the most part got this to work), but there’s no straightforward (or secure, at least) way to pass the password. If I set up a scheduled task to run the script as a domain user with local admin privs, the environment variables get lost. I need to run this script automagically so that there should be no user interaction.
If I could figure out how to make a scheduled task run as another user but keep the current user’s environment, I think this would work, but I’ve been beating my head against that for a while now, without any luck.
© Server Fault or respective owner