Solved

how to delete outlook signature file with VBS

Posted on 2013-02-04
3
2,088 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
Use email signature images to promote corporate certifications and industry awards.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

15 Experts available now in Live!

Get 1:1 Help Now