Solved

how to delete outlook signature file with VBS

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

790 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