Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

folder delete

Posted on 2011-03-23
11
Medium Priority
?
516 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
[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
  • 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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
 
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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Changing a few Outlook Options can help keep you organized!
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
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…
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…

688 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