Scripting Help

Alright, to keep it short, I’m deploying an Adobe Flash package through SCCM. It works well as is, unless IE is running. I can do a taskkill no problem, but I’d like to prompt the user before hand. This allruns in a .cmd file as of right now. Here is the “script”. I should mention I’m a n00b at this stuff, so before you ask “Why the hell are you doing it that way”, understand that this was the best method I could come up with.


@echo off

Color 04
Title Installing Adobe Flash Player
echo Installing Flash Player - Please Wait...
echo Window will close after install is complete

IF EXIST "C:\Program Files( x86)\" "%~dp0uninstall_flash_player_11.0.1.152_64bit.exe" -uninstall activex
IF NOT EXIST "C:\Program Files( x86)\" "%~dp0uninstall_flash_player_11.0.1.152_32bit.exe" -uninstall activex echo 32-bit OS detected
IF EXIST "C:\Program Files( x86)\" "%~dp0install_flash_player_11_active_x_64bit" -install
IF NOT EXIST "C:\Program Files( x86)\" "%~dp0install_flash_player_11_active_x_32bit" -install
if exist "%WINDIR%\system32\Macromed\Flash\" copy /Y "%~dp0mms.cfg" "%WINDIR%\system32\Macromed\Flash\"
if exist "%WINDIR%\SysWOW64\" copy /Y "%~dp0mms.cfg" "%WINDIR%\SysWOW64\"
REM Return exit code to SCCM
exit /B %EXIT_CODE%

If you put a “pause” command, it will wait before the users enters any key in the window before it closes all the windows.

Can I get a little more descriptive with it? Like “Installation needs to close Internet Explorer before continuing”

I can do it by popping up a DOS prompt/window

but a pretty windows message box

For the cmd script:

echo Press any key to close active windows and begin installation
pause
stuff here that will run after user hits enter (or any other key)

If you have the windows message service installed you can open a message box to get their attention. This will print message in teh CMD window, open a message box, and then wait for the user to press enter on the CMD window

echo Press enter to continue
msg “%username%” Please press enter on the main window
pause

I came up with a finished product and couldn’t use a notification to close IE since the package in SCCM was set to run hidden. It’s an optional package so users must select that they want to run this program manually. The script checks what bitness your OS is, then runs the appropriate Flash removal tool. Next the script force closes IE. Then it checks again to run the appropriate version of flash. After it copies a mms.cfg file to the appropriate location based on the OS version. This disables the “check for updates” feature bugging users to install the latest version, and have it fail because they aren’t admin.

@echo off

Color 04
Title Installing Adobe Flash Player
echo Installing Flash Player - Please Wait...
echo Window will close after install is complete

IF EXIST "C:\Program Files( x86)\" "%~dp0uninstall_flash_player_11.0.1.152_64bit.exe" -uninstall activex
IF NOT EXIST "C:\Program Files( x86)\" "%~dp0uninstall_flash_player_11.0.1.152_32bit.exe" -uninstall activex
TASKKILL /F /IM iexplore.exe /T
IF EXIST "C:\Program Files( x86)\" "%~dp0install_flash_player_ax_64bit" -install
IF NOT EXIST "C:\Program Files( x86)\" "%~dp0install_flash_player_ax_32bit" -install
if exist "%WINDIR%\system32\Macromed\Flash\" copy /Y "%~dp0mms.cfg" "%WINDIR%\system32\Macromed\Flash\"
if exist "%WINDIR%\SysWOW64\" copy /Y "%~dp0mms.cfg" "%WINDIR%\SysWOW64\"
REM Return exit code to SCCM
exit /B %EXIT_CODE%

May I ask why you just didn’t push it down from the domain controller at login?

We use SCCM for almost all our software distribution. Pushing it down through SCCM gives better reporting and more options. I can make it manditory, or not. I can have it run while the user is logged in, when they aren’t logged in, or either or. I can have it pushed to only Windows XP, only Vista, only Vista x64, etc. It’s A LOT nicer.

Alright, fuck everything above. I’m working on a simple Toolbar batch file. Basically I deal with enough desktops and laptops where I’d like to make a nice automated process. I’ll always continue to add to it with different variants of these piles of this.

Anyway, The google toolbar uses an msiexec string to uninstall with a specific (two different ones)…that part works fine. But then there is a manager piece that is random per install.

This is an example of what it looks like in the batch file:

"%PROGRAMFILES%\Google\Google Toolbar\Component\GoogleToolbarManager_<b>94DDE1EDD1CDF6A3</b>.exe" /uninstall

The part in red is what changes per install. Since I’m using quotes for the filepath any sort of wildcard won’t work. I need to know how I can uninstall this using some sort of variable.

RegEx is your friend.


@echo Off
CD "%PROGRAMFILES%\Google\Google Toolbar\Component\"
Dir /B&gt;Dir.temp
FindStr /R "GoogleToolbarManager_[A-Za-z0-9]" "Dir.temp"&gt;FindStr.temp
Del Dir.temp
For /F "tokens=*" %%a In (FindStr.temp) Do Call :DoWork"%%a"
Del FindStr.temp
Exit /B

:DoWork
"%PROGRAMFILES%\Google\Google Toolbar\Component\%1.exe" /uninstall
Exit /B

I can’t tell what it does though since the Exits close the batch file. Here is a full list with your code attached:

 TOOLBAR REMOVAL SCRIPT

REM========================================================================================
REM TOOLBAR REMOVAL SCRIPT
REM========================================================================================
REM========================================================================================
Color 04

REM========================================================================================
REM KILL ACTIVE BROWSERS
REM========================================================================================
REM========================================================================================
TASKKILL /F /T /IM iexplore.exe
TASKKILL /F /T /IM chrome.exe
TASKKILL /F /T /IM firefox.exe
TASKKILL /F /T /IM Safari.exe

@ECHO -----McAfee Toolbar-----


"%ProgramFiles(x86)%\McAfee Security Scan\uninstall.exe" -s
"%ProgramFiles%\McAfee Security Scan\uninstall.exe" -s


@ECHO -----Search Protect-----


"%ProgramFiles(x86)%\SearchProtect\bin\uninstall.exe" /S


@ECHO ------Television Bar-----

IF EXIST %ProgramFIles(x86)%\TELEVI~2\bar\" (
rundll32 "%ProgramFiles(x86)%\TELEVI~2\bar\1.bin\64Bar.dll",O 
) ELSE ( EXIT)


@ECHO -----Whitesmoke Toolbar-----


"%ProgramFiles(x86)%\WhiteSmoke_New\uninstall.exe" toolbar
"%ProgramFiles%\WhiteSmoke_New\uninstall.exe" toolbar


@ECHO -----Google Toolbar-----

@echo Off
CD "%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\"
Dir /B&gt;Dir.temp
FindStr /R "GoogleToolbarManager_[A-Za-z0-9]" "Dir.temp"&gt;FindStr.temp
Del Dir.temp
For /F "tokens=*" %%a In (FindStr.temp) Do Call :DoWork"%%a"
Del FindStr.temp
Exit /B

:DoWork
"%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\%1.exe" /uninstall
Exit /B

"%PROGRAMFILES%\Google\Google Toolbar\Component\GoogleToolbarManager_94DDE1EDD1CDF6A3.exe" /uninstall
"%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\GoogleToolbarManager_~.exe" /uninstall
MsiExec.exe /X {18455581-E099-4BA8-BC6B-F34B2F06600C} /QN
MsiExec.exe /X {18455581-E099-4BA8-BC6B-F34B2F06600C} /QN


@ECHO -----Yahoo Toolbar-----


%SYSTEMDRIVE%\PROGRA~2\Yahoo!\Common\UNYT_W~1.EXE


@ECHO -----AOL and AIM Toolbars-----


"%PROGRAMFILES%\AIM Toolbar\uninstall.exe" /S
"%PROGRAMFILES%\AOL Toolbar\uninstall.exe" /S


@ECHO -----Productivity Toolbar-----


"C:\Program Files\Productivity_3.1\uninstall.exe"


@ECHO -----MSN Toolbar-----


"C:\Program Files\MSN Toolbar Installer\InstallManager.exe" /UNINSTALL
MsiExec.exe /X {66468F4D-BC4E-470C-9093-B3B6A1BB378C} /QN
MsiExec.exe /X {BA5767FE-0C78-488F-84C1-A5288647C087} /QN


@ECHO -----AVG Toolbar-----


"C:\Program Files\AVG Secure Search\UNINSTALL.exe" /PROMPT /UNINSTALL


@ECHO -----Translator Toolbar-----


"C:\Program Files\TranslatorBar_1.2\uninstall.exe"


@ECHO -----Coupons.com Toolbar-----
"C:\Program Files\Coupons.com\uninstall.exe"


@ECHO -----ShopAtHome Toolbar-----


"C:\Program Files\ShopAtHome\ShopAtHomeUninstall.exe"
MsiExec.exe /X {05CE6E70-3F23-400E-AC99-17132A4C73AB} /QN
MsiExec.exe /X {995F1E2E-F542-4310-8E1D-9926F5A279B3} /QN


@ECHO -----Babylon Toolbar-----


"C:\Program Files\BabylonToolbar\BabylonToolbar\1.8.3.8\GUninstaller.exe" -nowait -ucrmex -uprtc -key BabylonToolbar


@ECHO -----Ask Toolbar-----


MsiExec.exe /X {86D4B82A-ABED-442A-BE86-96357B70F4FE} /QN


@ECHO -----Windows Upload Toolbar-----


MsiExec.exe /X {205C6BDD-7B73-42DE-8505-9A093F35A238} /QN


@ECHO -----vShare Plugin-----

"%ProgramFiles(x86)%\vShare\UNWISE.exe" /S
"%ProgramFiles%\vShare\UNINSTALL.exe" /S
"%ProgramFiles(x86)%\vShare\UNINSTALL.exe" /S


@ECHO -----Spam Free Search Bar-----


"%ProgramFiles%\blekkotb\uninstall.exe" /S
"%ProgramFiles(x86)%\blekkotb\uninstall.exe" /S

@ECHO -----DEAL BOAT------

"%Program Files(x86)%\Deal Boat\Uninstall.exe" /S
"%Program Files%\Deal Boat\Uninstall.exe" /S

@ECHO -----My FARM LIFE-----

"%SYSTEMDRIVE%\Remote Programs\My Farm Life 2\GPlrLanc.exe -LOpCode 2 /RemoveContent cid=748750;name=My Farm Life 2;dir=%SYSTEMDRIVE%\Remote Programs\My Farm Life 2\";prvid=143;cmdid=1;prvdir=Default

@ECHO -----Time Riddles-----

"%SYSTEMDRIVE%\Remote Programs\Time Riddles\The Mansion\GPlrLanc.exe" -LOpCode 2 /RemoveContent cid=683150;name=Time Riddles: The Mansion;dir="%SYSTEMDRIVE%\Remote Programs\Time Riddles\The Mansion\";prvid=143;cmdid=1;prvdir=Default

@ECHO -----VGrabber Toolbar-----
"%Program Files(x86)%\Vgrabber_v1\uninstall.exe" toolbar
PAUSE


You already have exits in there and echo off on the main script. Try this. I am doing this on the fly so haven’t tested anything. Basically it walks through the folder and looks for any regex match for GoogleToolbarManager_ and then should execute the uninstall using that path and the /uninstall flag.


TOOLBAR REMOVAL SCRIPT

REM========================================================================================
REM TOOLBAR REMOVAL SCRIPT
REM========================================================================================
REM========================================================================================
Color 04

REM========================================================================================
REM KILL ACTIVE BROWSERS
REM========================================================================================
REM========================================================================================
TASKKILL /F /T /IM iexplore.exe
TASKKILL /F /T /IM chrome.exe
TASKKILL /F /T /IM firefox.exe
TASKKILL /F /T /IM Safari.exe

@ECHO -----McAfee Toolbar-----


"%ProgramFiles(x86)%\McAfee Security Scan\uninstall.exe" -s
"%ProgramFiles%\McAfee Security Scan\uninstall.exe" -s


@ECHO -----Search Protect-----


"%ProgramFiles(x86)%\SearchProtect\bin\uninstall.exe" /S


@ECHO ------Television Bar-----

IF EXIST %ProgramFIles(x86)%\TELEVI~2\bar\" (
rundll32 "%ProgramFiles(x86)%\TELEVI~2\bar\1.bin\64Bar.dll",O 
) ELSE ( EXIT)


@ECHO -----Whitesmoke Toolbar-----


"%ProgramFiles(x86)%\WhiteSmoke_New\uninstall.exe" toolbar
"%ProgramFiles%\WhiteSmoke_New\uninstall.exe" toolbar


@ECHO -----Google Toolbar-----
CD "%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\"
Dir /B&gt;Dir.temp
FindStr /R "GoogleToolbarManager_[A-Za-z0-9]" "Dir.temp"&gt;FindStr.temp
Del Dir.temp
For /F "tokens=*" %%a In (FindStr.temp) Do Call :DoWork"%%a"
Del FindStr.temp

:DoWork
"%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\%1.exe" /uninstall
exit /B 1

"%PROGRAMFILES%\Google\Google Toolbar\Component\GoogleToolbarManager_94DDE1EDD1CDF6A3.exe" /uninstall
"%PROGRAMFILES(x86)%\Google\Google Toolbar\Component\GoogleToolbarManager_~.exe" /uninstall
MsiExec.exe /X {18455581-E099-4BA8-BC6B-F34B2F06600C} /QN
MsiExec.exe /X {18455581-E099-4BA8-BC6B-F34B2F06600C} /QN


@ECHO -----Yahoo Toolbar-----


%SYSTEMDRIVE%\PROGRA~2\Yahoo!\Common\UNYT_W~1.EXE


@ECHO -----AOL and AIM Toolbars-----


"%PROGRAMFILES%\AIM Toolbar\uninstall.exe" /S
"%PROGRAMFILES%\AOL Toolbar\uninstall.exe" /S


@ECHO -----Productivity Toolbar-----


"C:\Program Files\Productivity_3.1\uninstall.exe"


@ECHO -----MSN Toolbar-----


"C:\Program Files\MSN Toolbar Installer\InstallManager.exe" /UNINSTALL
MsiExec.exe /X {66468F4D-BC4E-470C-9093-B3B6A1BB378C} /QN
MsiExec.exe /X {BA5767FE-0C78-488F-84C1-A5288647C087} /QN


@ECHO -----AVG Toolbar-----


"C:\Program Files\AVG Secure Search\UNINSTALL.exe" /PROMPT /UNINSTALL


@ECHO -----Translator Toolbar-----


"C:\Program Files\TranslatorBar_1.2\uninstall.exe"


@ECHO -----Coupons.com Toolbar-----
"C:\Program Files\Coupons.com\uninstall.exe"


@ECHO -----ShopAtHome Toolbar-----


"C:\Program Files\ShopAtHome\ShopAtHomeUninstall.exe"
MsiExec.exe /X {05CE6E70-3F23-400E-AC99-17132A4C73AB} /QN
MsiExec.exe /X {995F1E2E-F542-4310-8E1D-9926F5A279B3} /QN


@ECHO -----Babylon Toolbar-----


"C:\Program Files\BabylonToolbar\BabylonToolbar\1.8.3.8\GUninstaller.exe" -nowait -ucrmex -uprtc -key BabylonToolbar


@ECHO -----Ask Toolbar-----


MsiExec.exe /X {86D4B82A-ABED-442A-BE86-96357B70F4FE} /QN


@ECHO -----Windows Upload Toolbar-----


MsiExec.exe /X {205C6BDD-7B73-42DE-8505-9A093F35A238} /QN


@ECHO -----vShare Plugin-----

"%ProgramFiles(x86)%\vShare\UNWISE.exe" /S
"%ProgramFiles%\vShare\UNINSTALL.exe" /S
"%ProgramFiles(x86)%\vShare\UNINSTALL.exe" /S


@ECHO -----Spam Free Search Bar-----


"%ProgramFiles%\blekkotb\uninstall.exe" /S
"%ProgramFiles(x86)%\blekkotb\uninstall.exe" /S

@ECHO -----DEAL BOAT------

"%Program Files(x86)%\Deal Boat\Uninstall.exe" /S
"%Program Files%\Deal Boat\Uninstall.exe" /S

@ECHO -----My FARM LIFE-----

"%SYSTEMDRIVE%\Remote Programs\My Farm Life 2\GPlrLanc.exe -LOpCode 2 /RemoveContent cid=748750;name=My Farm Life 2;dir=%SYSTEMDRIVE%\Remote Programs\My Farm Life 2\";prvid=143;cmdid=1;prvdir=Default

@ECHO -----Time Riddles-----

"%SYSTEMDRIVE%\Remote Programs\Time Riddles\The Mansion\GPlrLanc.exe" -LOpCode 2 /RemoveContent cid=683150;name=Time Riddles: The Mansion;dir="%SYSTEMDRIVE%\Remote Programs\Time Riddles\The Mansion\";prvid=143;cmdid=1;prvdir=Default

@ECHO -----VGrabber Toolbar-----
"%Program Files(x86)%\Vgrabber_v1\uninstall.exe" toolbar
PAUSE

Alright…have to run it from an elevated command prompt in Windows 7…That was my stupid fault. BUT, for some reason it doesn’t pick up the string name when you go to uninstall it. It tries to do a <FILEPATH>.exe /uninstall …Obviously that file doesn’t exist. Everything above that looks fine I think.

Hmmm. Debugging on the fly so need you to test for me. Take out the two del lines and post the text in the files in the google toolbar\components folder

Del Dir.temp
Del FindStr.temp