Jump to content


mikedisd

Deploy script to %username% using SYSTEM account

Recommended Posts

I need to deploy a package that runs a script using the current user's username. However, because SCCM uses the SYSTEM account, this changes the Windows environment variables (i.e., %username%, %userprofile%, etc.). I can't user the Run with user's rights because all user's are Standard Windows users and this needs Administrative rights.

 

I've come up with a nasty Powershell script that grabs the logged in user's account name using WMIC, then truncates the domain name (first 5 characters) and the spaces from the end. This then goes into a Powershell variable.

 

Is there an easier/better/more robust way of going about this? I thought this would be a rather common scenario; the need to push out a script that writes to the currently logged in user profile.

Share this post


Link to post
Share on other sites

Not sure if i understand you correct. You want to run a specific script to a user that's currently logged in?

 

Maybe this helps? The picture below is taken at the properties of a program inside a package. If you put %username% in the script, and execute it while the user is logged in it will fill in the blanks.

 

Properties.png

 

Good luck! ;)

Share this post


Link to post
Share on other sites

It's not that common because usually if an installation needs to be in the user directory, user rights are also sufficient. There are anly dirty workarounds in case your really needs the user directory and system credentials.

 

One last idea, whatever the installation is, try to split it up in a machine part and a user part. Run an installation with SYSTEM rights and set user settings with user rights.

  • Like 1

Share this post


Link to post
Share on other sites

One last idea, whatever the installation is, try to split it up in a machine part and a user part. Run an installation with SYSTEM rights and set user settings with user rights.

 

Ahh why didn't I think of that?? Thanks for such a simple solution. :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.