Jump to content

Post-install/1st Boot File Cleanup Question...


 Share

Recommended Posts

Hey everyone, I'm in need of deleting a lot of useless shortcuts created from some of my unattended setup disc, namely stuff like Favorites, Start Menu folders and links, etc. The problem is, none of the files show up until AFTER my batch file is finished and the Windows desktop & start-menu loads for the first time.

Does anyone have any recommendation how to get a 2nd batch file to run after the Windows desktop loads, preferably AFTER the 1st one finishes and after an automatic reboot?

Also, I'd like to add a DOS command that restarts Windows after the batch file completes. A timer would be nice too.

BTW, I've searched but the search is kinda... hinky sometimes. Couldn't quite find the words to describe what I was looking for and the closest match brought up numerous different things.

Thanks for the help in advanced guys. :thumbup

Link to comment
Share on other sites


Great, thanks for the info angadsingh007.

Another question.

If I put another batch file in the GuiRunOnce area, wont it just run right after my previous batch finishes? Or will it then load the Windows desktop THEN run the batch? I need the latter essentially and I'd test it right now but I've got a DVD-sized unattended setup and it takes a while to test.

Thanks again.

Link to comment
Share on other sites

"%systemdrive%\install\batch_file1.cmd"

The GuiRunOnce section is where you set the paths to batch files that run when Windows XP Setup has finished. These batch files run when the Admin account (or your own user account) is logged in.

According to the above info on MSFN's guide, all the batch files should run at Admin's logon.. that is at first logon...

They will run sequentially , that is one-by-one at first logon

Link to comment
Share on other sites

Hmm... my first batch file is in there, but it runs BEFORE the desktop appears. All that shows up is a DOS prompt window.

Is there any way I can get a batch to run after the desktop and the toolbar appears?

See, the links and files and whatnot only appear after the desktop and toolbar appear, so they cannot be deleted until then.

Link to comment
Share on other sites

Here is just a suggestion (and of course it will cause a bunch of replies).

I use AutoIt3 for ALL my installs. I wrote an AutoIt script for each install process. The last part of the AutoIt scripts does the following

1) Removes any ICONS on both the "Admin" and the "All Users" desktop

2) Moves ANY program groups from "Admin" to "All Users" (this way all uses have access to the program)

3) SOME installs move the program groups into groupings. For example all my DVD Tools are moved into a "DVD Tools" group on my start bar.

Learning AutoIt is VERY easy. Once you write a couple it very quick.

Link to comment
Share on other sites

I imagine the solution is very simple, but I'd like to see other suggestions.

Thanks bryanh, but I'd like to avoid 3rd party scripts if possible.

Maybe add an xcopy command in the 1st batch file to copy the 2nd batch file to the Startup folder of the admin's Start Menu? Then adding a DEL command to auto-delete the 2nd batch file for complete cleanup?

Link to comment
Share on other sites

Here is just a suggestion (and of course it will cause a bunch of replies).

I use AutoIt3 for ALL my installs.  I wrote an AutoIt script for each install process.  The last part of the AutoIt scripts does the following

1) Removes any ICONS on both the "Admin" and the "All Users" desktop

2) Moves ANY program groups from "Admin" to "All Users" (this way all uses have access to the program)

3) SOME installs move the program groups into groupings.  For example all my DVD Tools are moved into a "DVD Tools" group on my start bar.

Learning AutoIt is VERY easy.  Once you write a couple it very quick.

No need of using AutoIt. Batch will definitely do the job. This is my cleanup.cmd which runs at guirunonce :


cmdow @ /HID

REM install dialup connections
copy /y %SystemDrive%\rasphone.pbk "%allusersprofile%\Application Data\Microsoft\Network\Connections\Pbk"

REM Delete shortcuts from every all user's desktop
cd %ALLUSERSPROFILE%\Desktop
del /S /F /Q *.lnk
del /S /F /Q *.url

REM Delete shortcuts from every current user's desktop
cd %USERPROFILE%\Desktop
del /S /F /Q *.lnk
del /S /F /Q *.url

REM Delete all user's startup items
cd "%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
del /Q *.*

REM Delete current user's startup items
cd "%USERPROFILE%\Start Menu\Programs\Startup"
del /Q *.*

RD /S /Q "%systemdrive%\My Shared Folder"

del %systemdrive%\IrfanView_Install.log

regedit /s %SystemDrive%\cleanup.reg

REG DELETE HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx /f
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx /f

del /S /F /Q "%systemdrive%\Drivers"
del /S /F /Q "%systemdrive%\Applications"

RD /S /Q "%systemdrive%\Drivers"
RD /S /Q "%systemdrive%\Applications"

REM set paths

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /t REG_EXPAND_SZ /d "D:\Documents\Angad Singh" /f

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Favourites /t REG_EXPAND_SZ /d "D:\Documents\Angad Singh\Favourites" /f

del %SystemDrive%\cddrive_init.cmd
del %SystemDrive%\Drivers.exe
del %SystemDrive%\wpi.cmd
del %SystemDrive%\rasphone.pbk
del %SystemDrive%\phase2_init.cmd
del %SystemDrive%\cleanup.reg
del %SystemDrive%\cleanup.cmd

EXIT

@Judas989

Anway, if u want to run ur batch files after loading the desktop, then copy the batch file to the startup directory (%USERPROFILE%\Start Menu\Programs\Startup)

OR

a tricky solution wud be to make windows run a file called "run.cmd" with guirunonce...and include in it a statement

SLEEP 10
CALL <ur batch file>.cmd

This way, ur script will run after 10 seconds of delay, just enough for ur desktop to have loaded :thumbup

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...