1

I'm wondering about a script I made after the installation of my Windows 7 x64 ISO is done. The script (bat) contains this:

@echo off
cd C:\Users\
RD /S /Q "C:\Users\Public\"

cd C:\Users\Unknown\
ATTRIB +H "C:\Users\Unknown\Desktop"
RD /S /Q "C:\Users\Unknown\Searches"
RD /S /Q "C:\Users\Unknown\Saved Games"
RD /S /Q "C:\Users\Unknown\Videos"
RD /S /Q "C:\Users\Unknown\Links"
RD /S /Q "C:\Users\Unknown\Favorites"
RD /S /Q "C:\Users\Unknown\Contacts"

cd C:\
RD /S /Q "C:\PerfLogs\"
RD /S /Q "C:\Program Files\Uninstall Information"
RD /S /Q "C:\Program Files\Windows Media Player"
ATTRIB +H "C:\Program Files\Common Files" /S /D
ATTRIB +H "C:\Program Files\DVD Maker" /S /D
ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files\MSBuild" /S /D
ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files\Windows Defender" /S /D
ATTRIB +H "C:\Program Files\Windows Mail" /S /D
ATTRIB +H "C:\Program Files\Windows NT" /S /D
ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D

cd C:\Program Files (x86)\
RD /S /Q "C:\Program Files (x86)\Uninstall Information"
ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D




cd C:\ProgramData\Microsoft\Windows\Start Menu\
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"

cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"

C:\Windows\
RD /S /Q "C:\Windows\Downloaded Program Files"
RD /S /Q "C:\Windows\LiveKernelReports"
RD /S /Q "C:\Windows\Logs"
RD /S /Q "C:\Windows\ModemLogs"
RD /S /Q "C:\Windows\Offline Web Pages"
RD /S /Q "C:\Windows\Temp"
RD /S /Q "C:\Windows\WinToolkit"





cd C:\ProgramData\Microsoft\User Account Pictures\
REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"

How should I implant this script after the Win7 installation is done. Tried with SetupComplete (see spolier):

\sources\$OEM$\$$\Setup\Scripts


@ECHO OFF
cd %~dp0
attrib -R -A -S -H *.*
SHUTDOWN /R /T 5
RMDIR /S /Q "%WINDIR%\Setup\Scripts"

@echo off
cd C:\Users\
RD /S /Q "C:\Users\Public\"

cd C:\Users\Unknown\
ATTRIB +H "C:\Users\Unknown\Desktop"
RD /S /Q "C:\Users\Unknown\Searches"
RD /S /Q "C:\Users\Unknown\Saved Games"
RD /S /Q "C:\Users\Unknown\Videos"
RD /S /Q "C:\Users\Unknown\Links"
RD /S /Q "C:\Users\Unknown\Favorites"
RD /S /Q "C:\Users\Unknown\Contacts"

cd C:\
RD /S /Q "C:\PerfLogs\"
RD /S /Q "C:\Program Files\Uninstall Information"
RD /S /Q "C:\Program Files\Windows Media Player"
ATTRIB +H "C:\Program Files\Common Files" /S /D
ATTRIB +H "C:\Program Files\DVD Maker" /S /D
ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files\MSBuild" /S /D
ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files\Windows Defender" /S /D
ATTRIB +H "C:\Program Files\Windows Mail" /S /D
ATTRIB +H "C:\Program Files\Windows NT" /S /D
ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D

cd C:\Program Files (x86)\
RD /S /Q "C:\Program Files (x86)\Uninstall Information"
ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D




cd C:\ProgramData\Microsoft\Windows\Start Menu\
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"

cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"

C:\Windows\
RD /S /Q "C:\Windows\Downloaded Program Files"
RD /S /Q "C:\Windows\LiveKernelReports"
RD /S /Q "C:\Windows\Logs"
RD /S /Q "C:\Windows\ModemLogs"
RD /S /Q "C:\Windows\Offline Web Pages"
RD /S /Q "C:\Windows\Temp"
RD /S /Q "C:\Windows\WinToolkit"


cd C:\ProgramData\Microsoft\User Account Pictures\
REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"

Problem is, I can't use GPO either because I do prefer Home Premium.

1
  • 2
    You should paste only relevant parts of your programs, not everything you have.
    – Olli
    Feb 9, 2014 at 11:22

1 Answer 1

1

The Windows install disk isn't C:\ during installation, it's can be mounted as any drive, but is usually mapped to X:\

the best way to access the installation partition during setup is through %SystemDrive%\YOUR_PATH_HERE_FROM_ROOT

Assuming \Users\Unknown is the user account yet to be setup, it doesn't exist yet. and there is no variable named Unknown that pertains to user accounts, and if you've create an image of an installation with the user account Unknown, it'd be FAR easier to simply remove the folders from a mounted WIM, and basically hardcode the changes you want made.

Also, considering the start menu folders, you should include \* to remove any files in there to begin with, then on the following line remove the folder itself.

Also, you don't need to access the Program Data folder with %SystemRoot%, you can access it directly with %ProgramData% to save you some typing.

Further, why the hell are you telling the computer to shutdown in 5 seconds at the top of your script? why would you even risk not completing everything before it finished? put that at the end of the script, come on dude.

Here are some badly needed variables for you.

%ProgramData%, %SystemRoot%, %ProgramFiles%, %ProgramFiles(x86)% (%ProgramFiles(x86)% is dependent upon you running everything in x64 mode, if it's x86 both %ProgramFiles% AND %ProgramFiles(x86)% will return \Program Files(x86), which could easily mess your stuff up.)

2
  • Thank you for your answear but I felt that it was more advanced then I excepted. From your POV/mind it's harder to implant the script into SetupComplete. The username is "Unknown" as you said, correct. "and if you've create an image of an installation" -> You mean a .ISO? Why I don't want "*" it's because I want to remove certain folders and not everything inside the folder/folders. Please, could you help me further/explaining more in detail what I could do? Thank you so much for the answear, I'm atm only having this problem then I'm done with my installation! :D "Further, why the hell are you
    – user298600
    Feb 9, 2014 at 11:45
  • By image I meant install windows, do your stuff, and create an installation archive (install.wim in the sources folder) for reinstalling your customized version f windows on other computers. Ohh, that makes sense about not using asterisks (*), I'm confused as to what you still need help with?
    – MarcusJ
    Feb 9, 2014 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .