• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Script to install and uninstall program

johnsonlim027

OSNN Junior Addict
#1
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:
 

fitz

Woah.. I'm still here?
Staff member
Political User
#2
well.. gee..

what kind of program? what OS? what script language? is this an MSI install? Why not use GPO's?
 

madmatt

Bow Down to the King
Political User
#3
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
 

johnsonlim027

OSNN Junior Addict
#4
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 !!
 

madmatt

Bow Down to the King
Political User
#5
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".
 

johnsonlim027

OSNN Junior Addict
#6
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:

johnsonlim027

OSNN Junior Addict
#7
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:

fitz

Woah.. I'm still here?
Staff member
Political User
#8
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 posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,018
Latest member
timpage