zedox Posted February 3, 2006 Posted February 3, 2006 @echo offcmdow @ /HIDSetLocal enableextensionsSET CDROM=%~d0IF NOT DEFINED UserName FOR /F "tokens=3 delims=\" %%d IN ("%UserProfile%") DO SET UserName=%%dCOPY /Y "%CDROM%\$OEM$\system32\cmdow.exe" "%systemroot%\system32\"DEL /F /Q "%systemroot%\Web\Wallpaper\*.jpg"DEL /F /Q "%systemroot%\system32\*.scr"DEL /F /Q "%AllUsersProfile%\Documents\My Music"DEL /F /Q "%AllUsersProfile%\Documents\My Pictures"RD /S /Q "%AllUsersProfile%\Documents\Recorded TV"DEL /F /Q "%AllUsersProfile%\Start Menu\Activate Windows.lnk"DEL /F /Q "%AllUsersProfile%\Start Menu\Set Program Access and Defaults.lnk"DEL /F /Q "%AllUsersProfile%\Start Menu\Windows Update.lnk"DEL /F /Q "%AllUsersProfile%\Start Menu\Programs\Accessories\System Tools\Activate Windows.lnk"RD /S /Q "%UserProfile%\Favorites\Links"DEL /F /Q "%UserProfile%\My Pictures\"DEL /F /Q "%UserProfile%\Start Menu\Programs\Remote Assistance.lnk"DEL /F /Q "%UserProfile%\Start Menu\Programs\Windows Media Player.lnk"DEL /F /Q "%UserProfile%\Start Menu\Programs\Accessories\Windows Explorer.lnk"DEL /F /Q "%UserProfile%\Start Menu\Programs\Outlook Express.lnk"DEL /F /Q "%UserProfile%\Start Menu\Programs\Accessories\Address Book.lnk"EndLocalEXITThe last "DEL" commands are meant to remove the outlook express and address book shortcuts.But doesnt seem to work.The shortcuts only appear in the Administrators account. So what is the environment variable for the administrators account?
MHz Posted February 3, 2006 Posted February 3, 2006 The last "DEL" commands are meant to remove the outlook express and address book shortcuts.But doesnt seem to work.Outlook express shortcut seems to be created at 1st Active Desktop logon. I use a script from HKCU RunOnce to clean up these shortcuts.The shortcuts only appear in the Administrators account. So what is the environment variable for the administrators account?This is no environmental variable for the Administrator's profile. The code below should do it.%AllUsersProfile%\..\Administrator
Yzöwl Posted February 3, 2006 Posted February 3, 2006 IF NOT DEFINED UserName FOR /F "tokens=3 delims=\" %%d IN ("%UserProfile%") DO SET UserName=%%dAlthough %USERNAME% isn't used in your batch file, you could probably replace it with the following shorter code.if not defined username for %%? in ("%userprofile%") do set username=%%~nx?The quotes around the %userprofile% are needed just in case the username contains spaces and the x in the variable expansion just in case there is a stop in the username. It will help your code on occasions where the profile directory has been redirected to any location which is not one level below root i.edrive:\parent\username (the third token would be okay)drive:\windows\profiles\username (the third token would be incorrect)There may still be problems with even the improved code on some part installed systems however. If a user name has been changed, after creation of their profile folder its profile name often remains at the original thereby not holding the %username%.COPY /Y <snip>The /Y switch should not be required in a batch fileDEL /F /Q "%AllUsersProfile%\Documents\My Music"DEL /F /Q "%AllUsersProfile%\Documents\My Pictures"You may prefer to use RD for directory removalDEL /F /Q <snip>The /Q switch is only used to prevent prompts with wildcards and therefore not required with single named files.I hope this information helps!
Shark007 Posted February 3, 2006 Posted February 3, 2006 (edited) @ T-13/12/9 the %userprofile% doesn't exist yet.you need a 'logged in user' to have a %userprofile%at best, this variable would default to the "Default User' folder at these stages of installation.the %allusersprofile% is however available.try running your batch file by runounce or runonceex instead of T-12.shark Edited February 3, 2006 by Shark007
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now