Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook.exe /Importprf only run once via logon script

Posted on 2014-03-24
3
Medium Priority
?
1,855 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

604 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