Defprof via .bat file |
Post Reply |
Author | |
Tobias
Newbie Joined: 10 Jan 2013 Location: USA Status: Offline Points: 1 |
Post Options
Thanks(0)
Posted: 10 Jan 2013 at 9:42am |
Defprof is wonderful and you are saints for handing it out free.
I've written a batch file to load it into the system32 dir (why not) and run it for my helpers to save time typing dos commands. This is what I have so far: XCOPY %~dp0ad\DefProf\Defprof.exe C:\Windows\system32\ /Y start Defprof cola PAUSE So it copies defprof, opens a command prompt (as admin if you opened the batch file that way), and runs defprof. cola is the profile I've set up. I'm logged into it though, so it requires prompting "y" to pass through. I wish defprof would work without this prompt. I know I should create 2 accounts and run defprof from the other one, but I will defprof about 8 computers a day for the next several weeks as we frankenstein together old dells for use as gradstudent bullpen computers. If I could have a .bat that you just right click, run as administrator, reboot and call it done, I would have achieved the ultimate level of batch file laziness. Automation is sexy. |
|
-Toby
|
|
ne0fyt
Newbie Joined: 13 Feb 2013 Status: Offline Points: 2 |
Post Options
Thanks(0)
|
Hi Tobias,
Well, I just wrote a quick approach that does some logging and error handling, nothing special. This is what I've got so far: @echo off At >nul If Errorlevel 1 (Echo Error: Insufficient permissions && Goto :eof) If [%1]==[] (Echo Usage: %~n0 profilefoldername && Goto :eof) If [%1]==[%username%] (Echo Error: Different account required to apply "%~1" && Goto :eof) If Not Exist "%SystemDrive%\Users\%~1" (Echo Error: Account "%~1" doesn't exist && Goto :eof) Set Logfile="%~dp0%~n0.log" Echo Defprof "%~1" >%Logfile% Defprof "%~1" >>%Logfile% Echo. >>%Logfile% If Errorlevel 0 ( Reg load HKU\FirstLogin "%UserProfile%\..\Default\NTUSER.DAT" >nul Reg add HKU\FirstLogin\Software\Microsoft\Windows\CurrentVersion\Runonce /f /v firstlogin /d "c:\Users\firstlogin.cmd" >nul Reg unload HKU\FirstLogin" >nul If Errorlevel 0 (Echo Registry successfully updated. >>%Logfile%) Else (Echo Error: registry couldn't be updated. >>%Logfile% && Goto :eof) ) Else ( Echo Error: Default profile might be corrupt. >>%Logfile% && Goto :eof ) Echo. >>%Logfile% Echo Result: Default profile successfully updated. >>%Logfile% Exit @Developers: Are there return values reserved for specific errors? I found out that the command Defprof profilename may lead to a corrupt profile. Can I prevent this situation by checking the errorlevel value? I noticed that DefProf 1.6 won't keep symbolic links (Mklink /d) put in the customized new profile, so I call a runonce script for each newly created user fixing this... What's still missing is a section to backup the existing default user profile (haven't figured out how). Also very useful for flexibility would be a detailed exit code concept enabling to log what went wrong (as opening/writing ntuser.dat, applying registry changes etc.). Any developers reading along? |
|
ne0fyt
Newbie Joined: 13 Feb 2013 Status: Offline Points: 2 |
Post Options
Thanks(0)
|
There's a typo in the line
Reg unload HKU\FirstLogin" >nul The double quote must be deleted. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |