Possible to make user-specific setting changes when creating a new Windows user profile?

2

1

I'm configuring a Remote Desktop server, and each user account needs to have a predetermined but unique value set in a text (INI) file in %APPDATA% for a piece of software configuration.

I've created the necessary files and shortcuts for this to work in the C:\Users\Default profile, but would love a way to automate this INI file edit. Something like a find/replace for CHANGEME for %COMPUTERNAME%\%USERNAME% would be ideal, or an "append to end of file" would even work, I believe.

Is there some kind of scripting hook available for profile creation?

NReilingh

Posted 2013-12-24T02:41:46.523

Reputation: 5 539

Answers

2

It is possible to configure a RunOnce script that will run the first time a local profile is created. This involves editing the registry hive for the Default profile:

  1. Open regedit.exe
  2. Load the registry hive for the default user profile into the editor
    • Click on HKEY_USERS
    • Go to File -> Load Hive..
    • Load C:\Users\Default\NTUSER.DAT (NOT the .LOG file. It may be invisible; just type the filename manually if you have to.)
    • Give it whatever name you want; this doesn't do anything but give it a key name in the editor. For the example, we'll use "Temp"
  3. Navigate to Computer\HKEY_USERS\Temp\Software\Microsoft\Windows\CurrentVersion
  4. Create the RunOnce key here if it doesn't already exist.
  5. Change the string value under this key to the complete path of the executable/batch file to run.
  6. Click on the Temp key again, and File -> Unload Hive...

NReilingh

Posted 2013-12-24T02:41:46.523

Reputation: 5 539

1

I would use a first logon script, a simple batch file with this in it.

echo %COMPUTERNAME%\%USERNAME% >> %APPDATA%\my.ini

Output

BOX\KNUCKLE-DRAGGER

Knuckle-Dragger

Posted 2013-12-24T02:41:46.523

Reputation: 1 817

Imagine a situation where he has to setup douzends of new users: How would he automatically disable that first logon script after it was executed? – nixda – 2013-12-24T04:15:07.380

1Would you mind to include more details? Most users aren't aware of the RunOnce regkey – nixda – 2013-12-24T04:27:21.557