Script to install and uninstall program

johnsonlim027

OSNN Junior Addict
Joined
2 Dec 2005
Messages
26
I am going to write a script that run at the server to install and uninstall a particular program frrom the client once the user login to the domain.Does anyone have any idea or sample code to show?I have only the concept to write the script but have no idea to code it...first time doing this..:nervous:
 
well.. gee..

what kind of program? what OS? what script language? is this an MSI install? Why not use GPO's?
 
fitz is right. It depends on the OS and what kind of programs (i.e. executables, MSI, etc.)

Your best bet is to open command prompt, navigate to the directory where the file is, and typing "[program].[exe|msi] /?". Doing this will display the switches for such a program. A lot of executables and MSI have uninstall switches, some don't.

However, here is a script I wrote to update post-SP2 (XP) machines.

Code:
CLS
@echo off
TITLE Finalizing Windows XP Pro SP2

ECHO.
ECHO Installing HighMAT Extension for CD Writing Wizard...
ECHO Please Wait...
start /wait %systemdrive%\install\HMTCDWizard_enu.exe /qn

ECHO.
ECHO Installing Microsoft .NET Framework 2.0...
ECHO Please Wait...
start /wait %systemdrive%\install\dotnetfx\install.exe /qn

ECHO.
ECHO Installing PowerToy: Alt-Tab Replacement...
ECHO Please Wait...
start /wait %systemdrive%\install\pt-alttab.exe /s /v/qn

ECHO.
ECHO Installing PowerToy: ClearType Tuner...
ECHO Please Wait...
start /wait %systemdrive%\install\pt-ctype.exe /s /v/qn

ECHO.
ECHO Installing PowerToy: Image Resizer...
ECHO Please Wait...
start /wait %systemdrive%\install\pt-image.exe /s /v/qn

ECHO.
ECHO Installing PowerToy: Open Command Window Here...
ECHO Please Wait...
start /wait %systemdrive%\install\pt-cmdwin.exe /s /v/qn

ECHO.
ECHO Installing Tweak UI 2.10...
ECHO Please Wait...
start /wait %systemdrive%\install\tweakui.exe

ECHO.
ECHO Installing Windows Media Player 10...
ECHO Please Wait...
start /wait %systemdrive%\install\MP10Setup.exe /q

ECHO.
ECHO Installing Windows Media Connect 2.0...
ECHO Please Wait...
start /wait %systemdrive%\install\wmcsetup.exe /quiet

ECHO.
ECHO Installing Windows Messenger 5.1...
ECHO Please Wait...
start /wait %systemdrive%\install\messenger.msi /qn

ECHO.
ECHO Installing Windows Update Agent 2.0...
ECHO Please Wait...
start /wait %systemdrive%\install\updateagent\wusetup.exe /quiet

ECHO.
ECHO Beginning Windows Cleanup...

ECHO.
ECHO Applying Registry Tweaks...
REGEDIT /S "%systemdrive%\install\regtweaks.reg"

ECHO.
ECHO Copying System32 Files...
XCOPY "%systemdrive%\install\copy\oeminfo.ini" "%systemroot%\system32" /Q /Y
XCOPY "%systemdrive%\install\copy\oemlogo.bmp" "%systemroot%\system32" /Q /Y
XCOPY "%systemdrive%\install\copy\uptime.exe" "%systemroot%\system32" /Q /Y

ECHO.
ECHO Deleting Wallpapers...
DEL /Q "%systemroot%\*.bmp"
DEL /Q "%systemroot%\Web\Wallpaper\*.jpg"

ECHO.
ECHO Deleting Temp Files...
DEL /S /Q "%userprofile%\Local Settings\Temp\*.*"
DEL /S /Q "%systemroot%\Temp\*.*"

ECHO.
ECHO Deleting Shortcuts...
DEL /Q "%allusersprofile%\Start Menu\Activate Windows.lnk"
DEL /Q "%allusersprofile%\Start Menu\Windows Catalog.lnk"

ECHO.
ECHO Setting Up Start Menu...
MKDIR "%allusersprofile%\Start Menu\Programs\Tools"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Accessories\Accessibility" "%allusersprofile%\Start Menu\Programs\Tools"

MKDIR "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%allusersprofile%\Start Menu\Windows Update.lnk" "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%allusersprofile%\Start Menu\Set Program Access and Defaults.lnk" "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Accessories\Communications" "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Accessories\System Tools" "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%userprofile%\Start Menu\Programs\Remote Assistance.lnk" "%userprofile%\Start Menu\Programs\Tools"
MOVE /Y "%userprofile%\Start Menu\Programs\Accessories\Accessibility" "%userprofile%\Start Menu\Programs\Tools"
XCOPY "%userprofile%\Start Menu\Programs\Accessories\Command Prompt.lnk" "%userprofile%\Start Menu\Programs\Tools" /Q /Y
XCOPY "%userprofile%\Start Menu\Programs\Accessories\Notepad.lnk" "%userprofile%\Start Menu\Programs\Tools" /Q /Y
XCOPY "%userprofile%\Start Menu\Programs\Accessories\Windows Explorer.lnk" "%userprofile%\Start Menu\Programs\Tools" /Q /Y
XCOPY "%userprofile%\Start Menu\Programs\Tools\Communications\Remote Desktop Connection.lnk" "%userprofile%\Start Menu\Programs\Tools" /Q /Y

MOVE /Y "%allusersprofile%\Start Menu\Programs\Powertoys for Windows XP\Tweak UI.lnk" "%userprofile%\Start Menu\Programs\Tools"
RD /S /Q "%allusersprofile%\Start Menu\Programs\Powertoys for Windows XP"
RD /S /Q "%userprofile%\Start Menu\Programs\Powertoys for Windows XP"

MKDIR "%allusersprofile%\Start Menu\Programs\Microsoft"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Accessories\Entertainment" "%allusersprofile%\Start Menu\Programs\Microsoft"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Windows Media Connect.lnk" "%allusersprofile%\Start Menu\Programs\Microsoft\Entertainment"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Windows Movie Maker.lnk" "%allusersprofile%\Start Menu\Programs\Microsoft"

MKDIR "%userprofile%\Start Menu\Programs\Microsoft"
MOVE /Y "%allusersprofile%\Start Menu\Programs\Windows Messenger.lnk" "%userprofile%\Start Menu\Programs\Microsoft"
MOVE /Y "%userprofile%\Start Menu\Programs\Accessories\Entertainment" "%userprofile%\Start Menu\Programs\Microsoft"
XCOPY "%userprofile%\Start Menu\Programs\Internet Explorer.lnk" "%userprofile%\Start Menu\Programs\Microsoft" /Q /Y
XCOPY "%userprofile%\Start Menu\Programs\Windows Media Player.lnk" "%userprofile%\Start Menu\Programs\Microsoft" /Q /Y

ECHO.
ECHO Windows Cleanup Complete

PAUSE

DEL /S /Q "%userprofile%\Desktop\Connect to the Internet.lnk"
DEL /S /Q "%userprofile%\Start Menu\Programs\Outlook Express.lnk"

ECHO.
ECHO Restarting Windows...
shutdown.exe -r -f -t 60 -c "Windows will be restarted in 60 seconds..."

ECHO.
ECHO Deleting Installation Files...
RD /S /Q %systemdrive%\install

EXIT
 
I am going to install Open Office 2.0 and uninstall Open Office 1.1.4 from the client computer.All the client computer are using Windows XP Professional.I am going to write the script using Visual Basic Script or batch file format.Is there any web site to recommend?
Thanks MADMATT AND FITZ !!
 
If in fact you are going to use scripting to accomplish this task you will need the switches (and silent switches). You can refer to my post for more information or search the web for "BATCH SCRIPTING".
 
What is the silent switches that you mean?I don't understand..MadMatt, how I put in the script and where to put in the script so that it will run at the OU level..
 
Last edited:
my code is as follow:

CLS
@echo off
ECHO.
ECHO Installing OO 2.0
ECHO Please Wait...
start /wait %systemdrive%\OO2.0\setup.exe /qn


When I try to run it in the command prompt,nothing is coming out but suppose the Install menu should come out and allow user to install the program.Does anyone have idea on this on what is mising out?
 
Last edited:
johnsonlim027 said:
my code is as follow:

CLS
@echo off
ECHO.
ECHO Installing OO 2.0
ECHO Please Wait...
start /wait %systemdrive%\OO2.0\setup.exe /qn


When I try to run it in the command prompt,nothing is coming out but suppose the Install menu should come out and allow user to install the program.Does anyone have idea on this on what is mising out?

1) I'm assuming that you have a c:\OO2.0\setup.exe copied out to each workstation that you are going to install this to - because if your batch file is referencing the %systemdrive% that will be the local HD on the machine.

2) Is the /qn switch for the setup.exe a valid switch?

3) Do you want the user to have to walk through the install? Or do you want it to be a completly scripted install without user input?

Check out some of the installation documentation already available for Open Office.. here, in particular, are some that might be helpful to you:

How do I perform a silent install?

How can I install OpenOffice.org so that it can be used by multiple users on the same machine?

Is it possible to install OpenOffice.org without the user having to input data?
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back