Created
July 7, 2016 05:16
-
-
Save priceflex/876edcfd097d3a66d7fe1a2d72e95977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'*************************************************** | |
' File: auto_outlook.vbs | |
' Author: Mark M Manning | |
' Date: 10/10/2007 | |
' Version: 1 | |
' Based on the work of Peder Pedersen - [email protected] | |
'*************************************************** | |
Option Explicit | |
Dim Company, PRFLocation, ProfileName | |
' ========================================= | |
' ====== EDIT THIS INFORMATION============= | |
Company = "SEMO CTC" ' SET THE NAME OF YOUR COMPANY | |
'PRFLocation = "c:\test.prf" ' SET THE LOCATION ON THE NETWORK OR LOCAL DRIVE | |
PRFLocation = "\\servername\share\Workstations.PRF" ' OF THE PRF THAT HAS BEEN CREATE | |
ProfileName = "Default" ' This is the name that you have already | |
' created when you made the PRF. | |
' make sure they are the same | |
' ========================================= | |
' =================DO NOT EDIT ANYTHING BELOW THIS SECTION================ | |
' ======================================================================== | |
Set WshShell = CreateObject("WScript.Shell") | |
Set WshNetwork = Wscript.CreateObject("Wscript.Network") | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set ObjEnv = WshShell.Environment("Process") | |
Set objShell = CreateObject("Shell.Application") | |
Set objSysInfo = CreateObject("ADSystemInfo") | |
Set objUser = GetObject("LDAP://" & objSysInfo.UserName) | |
Const HKEY_CURRENT_USER = &H80000001 | |
Dim HKCUfirstRunflag | |
HKCUfirstRunflag = "HKCU\Software\" & Company & "\FirstRunFlag" | |
Dim HKCUprofile | |
HKCUprofile = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & ProfileName | |
Dim WshShell, WshNetwork, objEnv, fso, objShell, username, key, FirstRunCurrentUser, MSOKey, NoProfile, OfficeInstalled, strUserName, strInitials | |
Dim strOfficePath, strMachineName, objSysInfo, objUser | |
Dim objWord, LogonSrv, PRFPath, result, OSnummer, objWMIService, colOperatingSystems, objOperatingSystem | |
strOfficePath = "Software\Microsoft\Office\11.0\Common\UserInfo" 'Path for office user info | |
strMachineName = "." | |
' ============== START OF MAIN SCRIPT ============== | |
'Check OS | |
' ========================================= | |
Set objWMIService = GetObject("winmgmts:" _ | |
& "{impersonationLevel=impersonate}!\\" & strMachineName & "\root\cimv2") | |
Set colOperatingSystems = objWMIService.ExecQuery _ | |
("Select * from Win32_OperatingSystem") | |
For Each objOperatingSystem in colOperatingSystems | |
result = objOperatingSystem.Version | |
OSnummer = Left(result,3) | |
if OSnummer <> "5.1" then | |
'Wscript.Echo "This is not XP" 'Debug | |
Wscript.Quit | |
else | |
'Wscript.Echo OSnummer 'Debug | |
end if | |
Next | |
' ========================================= | |
'Test to see if the script has run before | |
' ========================================= | |
TestfirstRunUser ' Has script been run before? | |
If FirstRunCurrentUser then 'If not then continue | |
TestProfile | |
If NoProfile then 'Set up profile if none exists | |
OutlookSetup 'Setup Outlook profile | |
End if | |
end if | |
' ========================================= | |
' Add a registry key if the script runs successfully | |
WshShell.RegWrite HKCUfirstrunflag, "1", "REG_DWORD" | |
cleanup | |
' ================================================ | |
' ============== END OF MAIN SCRIPT ============== | |
' ================================================ | |
' -------- Test if first run for this user? | |
Sub TestFirstRunUser | |
on error resume next 'cannot be read first time | |
key = WshShell.RegRead(HKCUfirstRunflag) | |
If Err <> 0 Then | |
FirstRunCurrentUser = True | |
Else | |
FirstRunCurrentUser = False | |
End If | |
On Error Goto 0 | |
End Sub | |
'------------ Test if profile exists? | |
Sub TestProfile | |
on error resume next 'cannot be read first time | |
MSOKey = WshShell.RegRead(HKCUprofile) | |
' determine if a profile has already been setup | |
If MSOKey = "" Then | |
'wscript.echo "No Profile" 'Testing | |
NoProfile = True | |
else | |
'wscript.echo "Profile exists" 'Testing | |
NoProfile = False | |
end if | |
On Error Goto 0 | |
End sub | |
Sub OutlookSetup | |
WshShell.Run "outlook.exe /importprf " & PRFLocation, 1, False | |
End Sub | |
Sub Cleanup | |
Set WshNetwork = Nothing | |
Set objSysInfo = Nothing | |
Set WshShell = Nothing | |
Set fso = Nothing | |
Set ObjEnv = Nothing | |
Set objShell = Nothing | |
Set objUser = Nothing | |
Set objWord = Nothing | |
Set objWMIService = Nothing | |
Set colOperatingSystems = Nothing | |
Set objWord = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment