Solved

Outlook.exe /Importprf only run once via logon script

Posted on 2014-03-24
3
1,703 Views
Last Modified: 2014-03-25
Hi,

I have Win7 users located in DomainB Active Directory who access their mailbox which is located in DomainA.  The mailboxes are getting migrated onto an exchange server in DomainB.  Therefore I needed to run the outlook.exe /importprf for the existing users to update the outlook profile (these are not users who haven't logged on before).  I did this by using a small vbs script execute at user logon via Group Policy (user policy):

Dim objShell : Set objShell = CreateObject("Wscript.Shell")
strProgramPath = "Outlook.exe /importprf \\server.domain.local\share\new.prf"
objShell.Run strProgramPath

This works really well & the user is then pointed to the mailbox on DomainB.  My only problem is that this script runs on every user logon, but I only need this to run once for all the users.

Is anyone aware of the syntax I need to add into my script so that this updates the FirstRun / First-Run reg key so that it won't run again after initial execution?

Sorry - I'm not a scripter so you may have to tell me the actual lines I need to add.

Thanks.
0
Comment
Question by:meepmaker
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 39953064
i dont believe the firstrun process will work for you as the login script would just keep deleting the key after Outlook added it back again.


i would have to check for a  dummy text file on running the script. if file does not exist, then the update hasnt run yet.... so create the text file and run update

something like this code.  The login script would continue to be applied until all users were migrated across.
'-------------------------------------------------	
option explicit
' Constants for opening files
''''''''''''''''''''''''''''''''''
Const OpenFileForReading = 1
Const OpenFileForWriting = 2
Const OpenFileForAppending = 8

	dim prflocation, lf

	prflocation="\\server.domain.local\share\new.prf"
	lf = "Outlook_profile.Update"

	dim oNet, objShell, fso
	dim profile_path, lfl, tslf
	dim datetime, strProgramPath
	
	Set oNet = CreateObject("WScript.Network")
	Set objShell = CreateObject("WScript.Shell")
	datetime=Year(now()) & Right("0" & Month(now()), 2) & Right("0" & Day(now()), 2) & "=" & Right("0" & Hour(now()), 2) & Right("0" & Minute(now()), 2) '& Right("0" & Second(now()), 2)

	Set fso = CreateObject("Scripting.FileSystemObject")  
	'sysfld = fso.GetSpecialFolder(1)    'the system folder
	'winfld =  fso.GetSpecialFolder(0)   'the windows folder
	profile_path = objShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\"
	
	if(fso.FileExists(profile_path & lf)) Then
		'already done this profile
		wscript.echo "Already process profile update"
	else
		strProgramPath = "Outlook.exe /importprf " & prfLocation
		wscript.echo strProgramPath '<<<TESTING>>>>
		'objShell.Run strProgramPath
		
		' 
		Set tslf = fso.CreateTextFile(profile_path & lf,true)	

		tslf.Write (Onet.ComputerName & " , " & "BEGIN" & " , " & Datetime & vbCrLf)
		tslf.Close()
	
	end if

	set onet = nothing
	Set FSO = Nothing


	

Open in new window

0
 

Author Comment

by:meepmaker
ID: 39953250
Hi  Robberbaron,

Thats brilliant - thanks very much, I really appreciate your help.  I can now see the marker file being created at c:\Users\%Username%\Outlook_profile.Update

I don't actually need the Windows Script Host dialogue boxes stating "\\server.domain.local\share\new.prf" & "Already process profile update" & as I don't want the end user to see these - on relection I can see the wscript.echo at lines 29 & 32 - I guess you just need to comment these lines out?  I've done that now & I'm no longer presented with the Windows Script Host dialogue boxes.

Unfortuntely the importprf function within the script didn't work - this was simply due to line 33 being commented out.  After removing this comment - it works perfectly.

Thanks,
M
0
 

Author Closing Comment

by:meepmaker
ID: 39953595
Excellent response - exactly what I was looking for.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
smartboard connectivity and software 6 36
Mapped Network Drive Multiplying - Windows 7 - 64 Bit 6 31
Problem to With line 4 43
Turn on intranet settings 1 41
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now