Solved

how to delete outlook signature file with VBS

Posted on 2013-02-04
3
2,344 Views
Last Modified: 2013-02-04
hi all

i need to create a vbs script to delete a outlook signature from the signatures folder.
im fairly new to vbs scripting and im not sure which is the best way to go around this... ive seen plenty of examples of file name contains this and that...
but im totally confused as to what is the best process for me.

the difficulty here is that the file names created contain the username variable
what i mean by that is that the final name is called

ausamj_Signature.htm

every user has one of these, and every file is called AUS***_Signature.htm
this file resides in

C:\Users\ausamj\AppData\Roaming\Microsoft\Signatures


in regards to the scripting side, my understanding is that we need to find out first who is logged on, so i have a script for that.


Dim objNetwork
Dim userName
 
Set objNetwork = CreateObject("WScript.Network")
userName = objNetwork.UserName
 
WScript.Echo userName



and then somehow use the UserName variable to find the .htm file containing ausamj
and then delete it.... am i on the right path?


the reason why we cant delete *.htm is because users create their own signatures, so delete *.htm would remove all of them.
we only want to delete the standard one that is created by us.


so we need to find out who is logged on
locate the correct .htm file for the user, and then delete it.


appreciate if somebody could give me a hand with this


cheers!
0
Comment
Question by:BakerSyd
[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 16

Accepted Solution

by:
terencino earned 500 total points
ID: 38853632
Hi BakerSyd, how about this script below. It uses the Shell to extract the user profile of the logged in user, and FileSystemObject to delete the file.

Dim objNetwork, objShell, fso, userName
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject") 
userName = objNetwork.UserName
userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%")
SignatureFile = UserProfilePath & "\AppData\Roaming\Microsoft\Signatures\" & userName & "_Signature.htm"
fso.DeleteFile SignatureFile

Open in new window

0
 

Author Comment

by:BakerSyd
ID: 38853656
hey

that script is fantastic, does exactly what i want


thanks for your help !
0
 
LVL 16

Expert Comment

by:terencino
ID: 38853661
You're welcome, good luck with the implementation, and thanks for the grade!
0

Featured Post

Create Professional Looking Email Signatures

Create "Professional HTML Email Signatures" with ease.
7 Day Money Back Guarantee if not 100% Satisfied.
Affordable - Try it out for 7 Days Totally Risk Free.
Installers provided for over 45 Email clients.
Both Windows & MAC Supported.
Highly Recommended!

Question has a verified solution.

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

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

738 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