cschneegans / unattend-generator

.NET Core library to create highly customized autounattend.xml files
https://schneegans.de/windows/unattend-generator/
MIT License
659 stars 60 forks source link

The RunOnce script is not starting #35

Closed XerXes777 closed 3 months ago

XerXes777 commented 3 months ago

I have removed my actual scripts to make this clearer. Online Config

The registry entry in the key “Software\Microsoft\Windows\CurrentVersion\RunOnce” is written correctly in “NTUSER.DAT”. If I load it and look at the key and the value, it is correct. If I copy the value and execute it manually in cmd, the script is executed correctly.

However, the key is not copied to HKCU. When an admin logs on or when a user logs on. And therefore the script does not start automatically when a user logs on for the first time. I test the scripts in a VM with VMWare and without to have a Windows Key.

What am I doing wrong?

cschneegans commented 3 months ago

I have also experienced that modifying the default user's hive C:\Users\Default\NTUSER.DAT has the desired effect for some registry keys, but does not work for others. When adding new features I try to make them work by modifying the default users's hive first, and if that fails resort to the HKCU method.

For example, the per-user settings related to the Disable SmartScreen in Windows and Edge option work properly if applied to the default user's hive. On the other hand, the Use classic context (right-click) menu in Windows 11 option required adding a RunOnce script to set a value in HKCU.

I guess that the process to create new user accounts is more complex than simply copying the hive file, and Windows might use other data sources to populate certain registry keys.

XerXes777 commented 3 months ago

I have also experienced that modifying the default user's hive C:\Users\Default\NTUSER.DAT has the desired effect for some registry keys, but does not work for others. When adding new features I try to make them work by modifying the default users's hive first, and if that fails resort to the HKCU method.

Thank you for your answer. I have also often had the problem that some keys and values from NTUSER.DAT are not transferred to HKCU. I can't recognize a pattern yet. I actually already also had the idea of first setting everything in NTUSER.DAT and then checking it with a first start script in HKCU :D I already suspected the permissions of the keys.

I have inserted a pause at the end of the script for the purpose of searching for errors. The script is executed, but has problems with the permissions. My script cannot create a logfile under C:. And all output is redirected to the log file. how stupid of me. that's why i thought that the script is not executed at all, because no logfile is created.

I would also like to mention that without your website i would never have thought of dealing with this topic and actually switching to win11.