Generate User Profile without Logging in

email me

on error resume next

set ObjShell = CreateObject("WScript.Shell")
strComputerName = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%computername%")

Dim arrFileLines()
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("account_info_here.txt", 1)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close

'assign array item to variable
fname = arrFileLines(0)
lname = arrFileLines(1)
pword = arrFileLines(2)

'trim white space from beginning and end
fname = trim(fname)
lname = trim(lname)
pword = trim(pword)

strleft = left(fname,1)
comb = strleft & lname


‘The magic piece: code snippet

‘Runs an empty command (cmd.exe /c) using the user’s known username and password.
‘This forces Windows to create that user’s profile.

ObjShell.Run “C:\setup\scripts\cpau.exe -u ” & strComputerName & “\” & comb & ” -p ” & chr(34) & pword & chr(34) & ” -ex “”cmd.exe /c”” -lwp -wait”,0,true
WScript.Quit(0)