Solved VBS If username starts with, then

August 23, 2012 at 08:59:10
Specs: Windows XP
Hello,

We have about 50 computers that have an admin user and then a standard user that is one of a string, we'll call johndoe1,johndoe2.....johndoe50. Is there a way to write a script that pulls the profile that starts with "johndoe" then copy files to a location on that profile? Any assistance is appreciated.


See More: VBS If username starts with, then

Report •


✔ Best Answer
August 25, 2012 at 17:28:52
for /L %%a in (1,1,50) do (
echo y |DEL "C:\Documents and Settings\johndoe%%a\Desktop\*.*"
rmdir /s /q "C:\Documents and Settings\johndoe%%a\Local Settings\Temp"
echo y |DEL "C:\Documents and Settings\johndoe%%a\My Documents\My Pictures\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\Cookies\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\Start Menu\Programs\Startup\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\My Documents\*.*
)
:end
more code will be needed, but this is where I would start.


#1
August 23, 2012 at 10:25:03
This kinda sounds like something you should be using Group Policy to do.

How To Ask Questions The Smart Way


Report •

#2
August 23, 2012 at 14:10:07
I could do it using group policy but we'd be restricted to running the script every logon/logoff or startup/shutdown when I'd rather run the script every day using a scheduled task if possible.

Report •

#3
August 24, 2012 at 14:49:34
What are you attempting to do? There might be a better way to go about it, or it might be more challenging with VBScript.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
August 25, 2012 at 10:14:36
I actually wrote the wrong thing in my original post. I'm not trying to copy files to the profile, I'm trying to delete temporary files and clear the desktop, my docs, etc from a specific user profile on each computer. We have 1 user per computer(besides local and network admin users) going from johndoe1 to johndoe50. I have the batch code below that I use and it works but would like to have a generic file that can look up the usernames, pick out the johndoe user, and delete files from that profile. I used %username% and that works only for the user that is logged in but I need it to be able to run without being logged in. Sorry if this is confusing and jumbled but any help is much appreciated!

echo y |DEL "C:\Documents and Settings\johndoe1\Desktop\*.*"
rmdir /s /q "C:\Documents and Settings\johndoe1\Local Settings\Temp"
echo y |DEL "C:\Documents and Settings\johndoe1\My Documents\My Pictures\*.*"
echo y |DEL "C:\Documents and Settings\johndoe1\Cookies\*.*"
echo y |DEL "C:\Documents and Settings\johndoe1\Start Menu\Programs\Startup\*.*"
echo y |DEL "C:\Documents and Settings\johndoe1\My Documents\*.*


Report •

#5
August 25, 2012 at 17:28:52
✔ Best Answer
for /L %%a in (1,1,50) do (
echo y |DEL "C:\Documents and Settings\johndoe%%a\Desktop\*.*"
rmdir /s /q "C:\Documents and Settings\johndoe%%a\Local Settings\Temp"
echo y |DEL "C:\Documents and Settings\johndoe%%a\My Documents\My Pictures\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\Cookies\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\Start Menu\Programs\Startup\*.*"
echo y |DEL "C:\Documents and Settings\johndoe%%a\My Documents\*.*
)
:end
more code will be needed, but this is where I would start.

Report •


Ask Question