Solved

Outlook.exe /Importprf only run once via logon script

Posted on 2014-03-24
3
1,749 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

733 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