ForensiT Homepage
Forum Home Forum Home > ForensiT Support > Desktop Management
  New Posts New Posts RSS Feed - Defprof via .bat file
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Defprof via .bat file

 Post Reply Post Reply
Author
Message
Tobias View Drop Down
Newbie
Newbie


Joined: 10 Jan 2013
Location: USA
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tobias Quote  Post ReplyReply Direct Link To This Post Topic: Defprof via .bat file
    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
Back to Top
ne0fyt View Drop Down
Newbie
Newbie


Joined: 13 Feb 2013
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ne0fyt Quote  Post ReplyReply Direct Link To This Post Posted: 13 Feb 2013 at 3:11pm
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?
Back to Top
ne0fyt View Drop Down
Newbie
Newbie


Joined: 13 Feb 2013
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote ne0fyt Quote  Post ReplyReply Direct Link To This Post Posted: 15 Feb 2013 at 4:00pm
There's a  typo in the line
Reg unload HKU\FirstLogin" >nul
The double quote must be deleted.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.

This page was generated in 0.281 seconds.