Solved

folder delete

Posted on 2011-03-23
11
510 Views
Last Modified: 2012-05-11
We are switching our users from local signatures to a server based system.  Some users are ignoring this request so we want to send out a batch file to delete the signature folder on their machines so they have to switch:

to do this we need a wildcard command line:

so far i have this working except for the %username% part

rmdir /s /q  "C:\Documents and Settings\%username%\Application Data\Microsoft\Signatures"

we are on 95% windows xp machines.

thanks.
0
Comment
Question by:randy672
  • 4
  • 4
  • 3
11 Comments
 
LVL 8

Expert Comment

by:MarkieS
ID: 35199250
Use "%userprofile%\Application Data\Microsoft\Signatures"

This takes into account users who have married so the profile is still under the maiden name..
0
 

Author Comment

by:randy672
ID: 35199321
that didn't work
0
 
LVL 8

Expert Comment

by:MarkieS
ID: 35199413
If you run a CMD prompt and just type

cd "%userprofile%\Application Data\Microsoft\Signatures"

What do you get?  
0
 
LVL 8

Expert Comment

by:MarkieS
ID: 35199448
How are you running your batch file?  If it's running under the system account there is no user profile involved.  Is it part of an account login script or Group policy login script?
0
 

Author Comment

by:randy672
ID: 35199464
i am just running the command in CMD right now to test it.

when i type in cd "%userprofile%\Application Data\Microsoft\Signatures"  it give me can't find path specified, which makes sense since how would it know which profile i wanted to see.

All of our pcs have multiple profiles on them. I want to delete that folder on all of the profiles for each PC.
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 4

Expert Comment

by:MaximumIQ
ID: 35199466
the Envirnoment Variable MarkieS provided should work. the only thing I can think of is if the Signature folder or it's files have special persmissions assigned for some reason and the users don't have the access rights to remove it.

Have you tried running this manually in command line on one of your systems to see what's happening?
0
 

Author Comment

by:randy672
ID: 35199487
i am logged into the pc as a domain admin and I am running that line manually from the cmd prompt.

when i run this line it deletes the folder for that user:

rmdir /s /q  "C:\Documents and Settings\joeshmo\Application Data\Microsoft\Signatures"

when i run this one it doesn't work:

rmdir /s /q  "C:\Documents and Settings\%userprofile%\Application Data\Microsoft\Signatures"
0
 
LVL 4

Expert Comment

by:MaximumIQ
ID: 35199543
when you use %userprofile% it will return the current logged on use's profile path. Domain admins in most cases don't cache a local profile, which might explain why it's not finding that folder.

If you want to delete all users, you can write VB Script to look in the registry for all cached users and do a For...Next loop on each one.

Give me about 15 minutes I'll try to write you something.
0
 
LVL 8

Expert Comment

by:MarkieS
ID: 35199625
rmdir /s /q  "%userprofile%\Application Data\Microsoft\Signatures"

The %userprofile% is c:\documents and settings\<profilename"
0
 
LVL 4

Accepted Solution

by:
MaximumIQ earned 500 total points
ID: 35199777
Here is a script that I tweaked a bit for your case. Paste this code in a VBS File.

You just need to set a path to where you want a log file to save. If you dont want a log file just remove the "Set log =...." line and all "logfile.write..." lines

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

Dim strUserProfile
Dim FSO, WshNetwork, WshShell, Log

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = CreateObject("Wscript.Network")
Set WshShell = Wscript.CreateObject("Wscript.Shell") 

'Put a path on this next line where you want a log file to save
Set log = fso.getFile("Log Path Here")
Set logfile = log.OpenAsTextStream (ForAppending, TristateUseDefault)

strWinFolder =  fso.GetSpecialFolder(WindowsFolder)
strSysFolder =  fso.GetSpecialFolder(SystemFolder)

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

logfile.write WSHNetwork.UserName
logfile.write " ;"
logfile.write WSHNetwork.ComputerName
logfile.write " ;"
logfile.write time
logfile.write " ;"
logfile.write date
logfile.write " ;"

For Each objSubkey In arrSubkeys
    strValueName = "ProfileImagePath"
    strSubPath = strKeyPath & "\" & objSubkey
    objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue

	'Here is your line		
		If fso.FolderExists(strValue & "\Application Data\Microsoft\Signatures") Then 
			fso.deletefolder(strValue & "\Application Data\Microsoft\Signatures")
			logfile.write strValue & "\Application Data\Microsoft\Signatures"
		end if
Next

Open in new window

0
 

Author Closing Comment

by:randy672
ID: 35200366
Thanks!!!!
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now