Image

Image

Search This Blog

Sunday, March 09, 2014

Setup Outlook profile and hack the location of Documents

'Setup Outlook profile and hack the location of My Documents without GPO
'(c)2010 neXt

Set WshShell = CreateObject("WScript.Shell")
On error Resume Next

set env = WshShell.Environment("PROCESS")
Set WshNet = CreateObject("WScript.Network")
homedrv =  wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEDRIVE")
homedir = wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEPATH")
strUsername = WshNet.Username
if (IsEmpty(homedrv) Or IsEmpty(homedir)) then
        dim WshNet, WMIService, Account
        Set WshNet = WScript.CreateObject("WScript.Network")
        Set WMIService = GetObject("winmgmts:\\.\root\cimv2")
        Set Account = WMIService.Get("Win32_UserAccount.Name='" & WshNet.UserName & "',Domain='" & WshNet.UserDomain & "'")

        userprofile = WshShell.ExpandEnvironmentStrings(WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" + Account.SID
 + "\ProfileImagePath"))
else

        userprofile = homedrv & homedir
end if

set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("c:\Users\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Users\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Users\" & strUsername & "\Documents"
End If

If objFSO.FolderExists("c:\Utilisateurs\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Utilisateurs\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Utilisateurs\" & strUsername & "\Documents"

End If

If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\My Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\My Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\My Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\My Documents"
End If

If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\Mes Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\Mes Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\Mes Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\Mes Documents"
End If

WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_SZ"
'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_EXPAND_SZ"

'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"

Blog Archive