?
Solved

Outlook Signature Script Error

Posted on 2013-05-17
5
Medium Priority
?
615 Views
Last Modified: 2013-05-28
We have a outlook signature script that runs every time a user logs on a computer. The script runs flawlessly unless it is their first time logging on the computer. If it is their first time the script gives an error (attached). Is there a way of creating the signature directory without running outlook? It looks like the script will fail unless the user has a outlook profile on the computer. This particuarly happens in meeting rooms where the user doesn't normally login. I also attached the script for reference.

Thanks!
OutlookSig1-Example.vbs
Script-Error.PNG
0
Comment
Question by:ICCNetworkAdmin
[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
5 Comments
 
LVL 6

Expert Comment

by:Alan Gunn
ID: 39175139
What a cool script!

Unfortunatley, as you surmise, the registry won't contain the required keys until the user logs on and starts Outlook.

If you have a domain and central storage of some kind you could set up roaming profiles.

In this scenario, the "User" registry keys and potentially other specific folders are stored centrally and are applied to each machine that the user logs into.

Could be worth a look. :-)

Cheers!

TRM
0
 
LVL 82

Accepted Solution

by:
David Johnson, CD, MVP earned 1000 total points
ID: 39175357
Here is the modified script
 Set objUser = CreateObject("WScript.Network")
userName = objUser.UserName
domainName = objUser.UserDomain 

FUNCTION GetUserDN(BYVAL UN, BYVAL DN)
Set ObjTrans = CreateObject("NameTranslate")
objTrans.init 1, DN
objTrans.set 3, DN & "\" & UN
strUserDN = objTrans.Get(1)
GetUserDN = strUserDN
END FUNCTION

Set objLDAPUser = GetObject("LDAP://" & GetUserDN(userName,domainName))

Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile, plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
'
' added section
'
pathToCopyTo = appDataPath & "\Microsoft\Signatures\"
If Not objFSO.FolderExists(pathToCopyTo) Then
   objFSO.CreateFolder(pathToCopyTo)
End If
'
' end of modified Section
'
plainTextFilePath = pathToCopyTo & "Default.txt"
Set plainTextFile = objFSO.CreateTextFile(plainTextFilePath, TRUE)
plainTextFile.WriteLine(objLDAPUser.FirstName & " " & objLDAPUser.LastName)
plainTextFile.WriteLine(objLDAPUser.title)
plainTextFile.WriteLine ("Insert Company Here")
plainTextFile.WriteLine [BR]
If Len(objLDAPUser.physicalDeliveryOfficeName) > 1 THEN
	IF  CStr(REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "")) >  200 THEN
		plainTextFile.WriteLine("Insert Phone Here" & REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "" ) & " (Direct) ")
	ELSE
		plainTextFile.WriteLine("Insert Phone Here" & REPLACE(objLDAPUser.physicalDeliveryOfficeName, "x", "") & " (Direct) ")
	END If
END If
IF  Len(objLDAPUser.telephoneNumber) > 3 THEN
  plainTextFile.WriteLine(objLDAPUser.telephoneNumber & " " & "(Cell)")
END If
 
plainTextFile.WriteLine( "(xxx) xxx-xxxx (Fax) " )
plainTextFile.Close

Open in new window

0
 

Author Comment

by:ICCNetworkAdmin
ID: 39176682
Unfortunatly the modified script did not put any signatures in outlook when the profile was created.
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 1000 total points
ID: 39201105
Is it the absence of a Signature folder that's causing the error?  If so, then yes, you can create the folder outside of Outlook.  Add this code to the script you already have and insert a call to it immediately after this line

Set objWsh = CreateObject("WScript.Shell")

Sub CreateSigFolder()
    Dim objFSO, objShl, strFld
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShl = CreateObject("WScript.Shell")
    strFld = objShl.ExpandEnvironmentStrings("%AppData%") & "\Microsoft\Signatures"
    If Not objFSO.FolderExists(strFld) Then objFSO.CreateFolder (strFld)
    Set objFSO = Nothing
    Set objFld = Nothing
End Sub

Open in new window

0
 

Author Closing Comment

by:ICCNetworkAdmin
ID: 39201945
Thank you for the help! With the help of ve3ofa and BlueDevilFan the script is now working as needed. We backed away from the Default part because some users were complaining but as for the error it no longer appears.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

765 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