Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *windowsalarms* | Remove-AppxPackage
Get-AppxPackage *Appconnector* | Remove-AppxPackage
Get-AppxPackage *windowscalculator* | Remove-AppxPackage
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
Get-AppxPackage *windowscamera* | Remove-AppxPackage
Get-AppxPackage *CandyCrushSaga* | Remove-AppxPackage
Get-AppxPackage *officehub* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
Get-AppxPackage *getstarted* | Remove-AppxPackage
Get-AppxPackage *zunemusic* | Remove-AppxPackage
Get-AppxPackage *windowsmaps* | Remove-AppxPackage
Get-AppxPackage *Messaging* | Remove-AppxPackage
Get-AppxPackage *solitairecollection* | Remove-AppxPackage
Get-AppxPackage *ConnectivityStore* | Remove-AppxPackage
Get-AppxPackage *bingfinance* | Remove-AppxPackage
Get-AppxPackage *zunevideo* | Remove-AppxPackage
Get-AppxPackage *bingnews* | Remove-AppxPackage
Get-AppxPackage *onenote* | Remove-AppxPackage
Get-AppxPackage *people* | Remove-AppxPackage
Get-AppxPackage *CommsPhone* | Remove-AppxPackage
Get-AppxPackage *windowsphone* | Remove-AppxPackage
Get-AppxPackage *photos* | Remove-AppxPackage
Get-AppxPackage *WindowsScan* | Remove-AppxPackage
Get-AppxPackage *bingsports* | Remove-AppxPackage
Get-AppxPackage *windowsstore* | Remove-AppxPackage
Get-AppxPackage *Office.Sway* | Remove-AppxPackage
Get-AppxPackage *Twitter* | Remove-AppxPackage
Get-AppxPackage *soundrecorder* | Remove-AppxPackage
Get-AppxPackage *bingweather* | Remove-AppxPackage
Get-AppxPackage *xboxapp* | Remove-AppxPackage
Get-AppxPackage *XboxOneSmartGlass* | Remove-AppxPackage
Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")
'-----------------------------------------------------------------------
' Run computer cleanup script
Set objShell = CreateObject("WScript.Shell")
strCleanup = strAppData & "\Scripts\Cleanup.exe"
objShell.run "cmd /c " & strCleanup,0,False
'-----------------------------------------------------------------------
WScript.Quit
Convert Launch.vbs to an executable (Launch.exe) and place it in Operator’s Startup folder. This file will get deleted on completion of Cleanup.exe. You should add this file just before you're ready to run sysprep as you may need to reboot your computer at different stages.
Set WshShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")
strLocalAppData = WshShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")
strUserProfile = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
strAllUsers = WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
'-----------------------------------------------------------------------
' ADD COMMANDS HERE
'-----------------------------------------------------------------------
' Delete Launch.exe
strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")
strLaunch = strAppData & "\Microsoft\Windows\Start Menu\Programs\Startup\Launch.exe"
If objFSO.FileExists(strLaunch) Then
objFSO.DeleteFile strLaunch, True
End If
'-----------------------------------------------------------------------
WScript.Quit
You can add any commands you like in this script. Here you can re-install OneDrive, which we will go over later in the guide. At the end of the script Launch.exe will get deleted so that it does not run again for the currently logged in user. Copy Cleanup.exe to %AppData%\Scripts. You will need to create the Scripts folder as it does not exist.
WinSAT prepop
This will generate the WinSAT prepop .xml results files to the Datastore directory, located at:
Powercfg –list
Look for your default power plan. Write down the guid for the plan. We will add this to your unattend.xml file later.
pnputil.exe -a HP0001.inf
The command needs to be run at an elevated command prompt. More information about this command can be found here.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsBackup]
"DisableMonitoring"=dword:00000001
Disable Password Reveal:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main]
"DisablePasswordReveal"=dword:00000001
Disable IE Suggested Sites:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Suggested Sites]
"Enabled"=dword:00000000
Note: You can also apply the registry files via group policy.
move "%LOCALAPPDATA%\Microsoft\OneDrive" "%LOCALAPPDATA%\Microsoft\OneDrive.old"
del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" /q/s
rd "%LOCALAPPDATA%\Microsoft\OneDrive.old" /q/s
rd "%USERPROFILE%\OneDrive" /q/s
To clean up the old OneDrive registry entries, create a registry file named OneDriveCleanup.reg using notepad and paste the following code. Run the registry file.
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\SOFTWARE\Microsoft\OneDrive]
Now you can add the following code to the Cleanup.exe file you created above to re-install OneDrive when the user logs in for the very first time.
' Run OneDrive Setup
strOneDrive = strAllUsers & "\Microsoft\OneDrive\Update\OneDriveSetup.exe /silent"
objShell.run "cmd /c " & strOneDrive,0,True
All folders will be recreated, including the All Apps shortcut.
<ComputerName>*</ComputerName>
This will allow sysprep to provide a random name for the computer after sysprep.
<CopyProfile>true</CopyProfile>
This tells sysprep to copy the configured profile you’ve created to the default profile.
<SkipRearm>0</SkipRearm>
Set SkipRearm to 1 while customizing your computer.
<PreferredPlan>your.guid</PreferredPlan>
This specifies the default power plan for your image. Update the unattend.xml file with the guid of the power plan you retrieved earlier.
<DisableAntiSpyware>true</DisableAntiSpyware>
Setting this to True will disable Windows Defender. Set this to False if you are not deploying your own antivirus program.
<MachineObjectOU>OU=Re-Imaged,OU=Computers,DC=your,DC=domain,DC=com</MachineObjectOU>
You must specify an OU to add the computers to otherwise they will not be added to the domain.
<DoNotCleanUpNonPresentDevices>true</DoNotCleanUpNonPresentDevices>
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
When set to True, this tells sysprep not to remove installed hardware from the image during sysprep. This should be the case when distributing the image to the same model computer. If you would like to create a clean sysprep image, meaning you are able to install the image on any computer, no matter the hardware, the above should be set to False.
net user TempUser /delete
To enable the local Administrator account, add the following command to SetupComplete.cmd:
net user Administrator /active:yes
Even though you may have enabled the administrator account on the imaged laptop before running sysprep, it will be disabled again.
net localgroup Administrators "Domain\Domain Users" /delete
net localgroup Users "Domain\Domain Users" /delete
To delete the unattend.xml file, add the following command to SetupComplete.cmd:
del C:\Windows\System32\Sysprep\unattend.xml
Even though the passwords you enter in the xml file are encrypted, you’ll feel better knowing the file is not there. I've attached a sample SetupComplete.cmd file for reference. You may add whatever commands you need to run here in this file. Save the file when finished.
sysprep.exe /generalize /oobe /shutdown /unattend:unattend.xml
The computer will shut down after sysprep has finished.
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (17)
Commented:
My local administrator won't reactivate after SYsprep :(. Got the script at the right place. any ideas ?
Btw im usin a French OS. so instead "Administrator" i put "Administrateur" is it right ?
I set the user account in oobe System.
Any help ? :(
Thx
Author
Commented:The SetupComplete.cmd should be located here:
C:\Windows\Setup\Scripts
The command that enables the Administrator account in this file should look like:
:: Enable local administrator user account
net user Administrator /active:yes
In regards to the spelling of Administrator. Take a look in "Local Users and Groups - Users". Administrator should be listed as a local user. Spell it the way you see it there.
Make sure all the commands above this line are valid. If there is a command that is not valid, it can stop other commands from processing.
Is there a group policy that may disable the Administrator account after the computer is added to the domain?
Ivano
Commented:
I'm new to Sysprep and have a simple embarrassing question.
From a new computer, I booted into Audit mode and got the setup I'm happy with after many many hours of learning. Since this is my first attempt, I want to capture an image of the setup I've spent so much time on PRIOR to running Sysprep and while in Audit mode in case - as you say - something goes wrong.
How do I make a "backup" image of the configuration prior to running Sysprep? I tried creating and Image from the Backup options of Control Panel but it says I'm not allowed while in Audit mode. But if I exit Audit mode, won't I loose everything?
I'm having a hard time understanding what happens to the configuration once you exit Audit mode.
Thank you for answering an embarrassing question.
Allan
Commented:
If you later want to restore your Windows, rename that wim file install.wim and put it in the sources folder on a normal Windows 10 setup USB stick created with Media Creation Tool.
Commented:
View More