Jump to content


bostonrake

Trying To Run Batch File to Uninstall an App

Recommended Posts

Hey all,

I'm trying to run a batch file that will uninstall Ultra VNC. When I run it from the computer locally or even from a server location, it works fine. I created the package in SCCM like I would for just about any other install package, but it doesn't work. I have tried several settings... drive letter, unc path, run from distribution point, run locally, etc... and several combinations of those settings.

 

I have read quite a bit on the net, but I'm still at a loss. I think I need to be using %~dp0

 

Here is what the batch looks like now...

 

if exist "C:\Program Files (x86)" goto 64bit

goto 32bit
:32bit
c:
cd \program files\ultravnc
unins000.exe /VERYSILENT /NORESTART
cd \program files\uvnc bvba\ultravnc
unins000.exe /VERYSILENT /NORESTART
taskkill /F /IM winvnc.exe
:64bit
c:
cd \program files (x86)\ultravnc
unins000.exe /VERYSILENT /NORESTART
cd \program files (x86)\uvnc bvba\ultravnc
unins000.exe /VERYSILENT /NORESTART
taskkill /F /IM winvnc.exe
Basically it goes to 2 possible locations and runs the uninstall. Then I added a taskkill because in one test, winvnc.exe was still running even after it uninstalled. Anyway, that's not what this about. I'm just trying to get this batch to run via SCCM 2007.
If I do need to use %~dp0, how would I do that with this batch file? I don't understand why that would be needed though... especially if I say to download the batch and run locally.
Thanks,
Doug

Share this post


Link to post
Share on other sites

Hi Doug,

 

You only need to use %~DP0 when you need to know your current working directory or reference another directory, say a sub directory.

an example are some of the adobe applications. Sometimes they have a setup.exe file and you have to reference the full path to a customisation xml.

 

In that case an example would be (both files in package root folder)

 

SETLOCAL
SET WORKING=%~dp0
%WORKING%Setup.exe %WORKING%custom.xml
This is specifying the full path to the setup.exe and the xml file.
If you just had a setup.exe and no custom xml to reference then just setup.exe on it's own as the command line would be fine.
another example for a response file:
Where the setup.exe is in a sub folder of your package called FOLDER and the response file is in a subfolder called FOLDER2
"%~dp0FOLDER\setup.exe" -s -f1"%~dp0FOLDER2\Setup.iss"
In your script I wouldn't bother with CD, there is no need, just put the full path to the file you want to run. There is no need to use ~dp0 in your example.
I would tackle your task with something like this:(not tested but might set you on the right path)
ECHO off
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT

if %OS%==32BIT SET APP_PATH1=C:\Program Files\Ultravnc\unins000.exe
if %OS%==32BIT SET APP_PATH2=C:\Program Files\Uvnc bvba\Ultravnc\unins000.exe
if %OS%==64BIT SET APP_PATH1=C:\Program Files (x86)\Ultravnc\unins000.exe
if %OS%==64BIT SET APP_PATH2=C:\Program Files (x86)\Uvnc bvba\Ultravnc\unins000.exe

if exist "%APP_PATH1%" (
    "%APP_PATH1%" /VERYSILENT /NORESTART
    EXIT /B %errorlevel%
) else (
    ECHO EXE not found
)

if exist "%APP_PATH2%" (
    taskkill /F /IM winvnc.exe 
    "%APP_PATH2%" /VERYSILENT /NORESTART
    EXIT /B %errorlevel%
) else (
    ECHO EXE not found
)

Have a look at execmgr.log on the client to see why your package fails to install.

Another troubleshooting step might be to download psexec and run your script with psexec -i -s cmd.exe

this will open a command window under the system account, the system account is the account ConfigMgr uses to do the install so great for testing.

Share this post


Link to post
Share on other sites

Thanks so much for the detailed reply. I made a batch file based off your code and it worked when I ran it from the server. However, like my original batch file, it is not working via SCCM.

 

Here some of the execmgr.log from my test machine.

 

<![LOG[Download content and mapped drive required. SC120145 - UltraVNC Uninstall DD not acceptable by client]LOG]!><time="15:43:52.693+360" date="01-21-2016" component="execmgr" context="" type="2" thread="5060" file="softdistpolicy.cpp:825">
<![LOG[OnPolicyActivation FindUserOrSystemPolicy returns invalid policy]LOG]!><time="15:43:52.693+360" date="01-21-2016" component="execmgr" context="" type="2" thread="5060" file="execreqmgr.cpp:7154">
<![LOG[Mandatory execution requested for program UltraVNC Uninstall DD and advertisement SC120145]LOG]!><time="15:43:52.694+360" date="01-21-2016" component="execmgr" context="" type="1" thread="4776" file="execreqmgr.cpp:3317">
<![LOG[Creating mandatory request for advert SC120145, program UltraVNC Uninstall DD, package SC1000AF]LOG]!><time="15:43:52.694+360" date="01-21-2016" component="execmgr" context="" type="1" thread="4776" file="execreqmgr.cpp:3440">
<![LOG[Download content and mapped drive required. SC120145 - UltraVNC Uninstall DD not acceptable by client]LOG]!><time="15:43:52.708+360" date="01-21-2016" component="execmgr" context="" type="2" thread="4776" file="softdistpolicy.cpp:825">
<![LOG[CreateMandatoryRequestRecursively reject invalid policy UltraVNC Uninstall DD]LOG]!><time="15:43:52.708+360" date="01-21-2016" component="execmgr" context="" type="2" thread="4776" file="execreqmgr.cpp:3480">
<![LOG[Download content and mapped drive required. SC120145 - UltraVNC Uninstall DD not acceptable by client]LOG]!><time="15:43:52.712+360" date="01-21-2016" component="execmgr" context="" type="2" thread="4776" file="softdistpolicy.cpp:825">
<![LOG[RaisePolicyStateStatusMessage - invalid policy received]LOG]!><time="15:43:52.712+360" date="01-21-2016" component="execmgr" context="" type="2" thread="4776" file="execreqmgr.cpp:368">
"mapped drive required" is some of the messages I was seeing yesterday before I started this thread. I'm missing something somewhere when I'm creating the package in sccm.
Thanks,
Doug

Share this post


Link to post
Share on other sites

Cool, no need for a mapped drive in the package. Just stick your bat or .cmd in a folder. Make that folder the source for the package and it will cache down to each machine.

Your command to run the bat is just the name of the .bat or .cmd

 

Hope you got it sorted.

Share this post


Link to post
Share on other sites

OK, I got this one working. I "think" it is working now because I told it to run from the distribution point and use unc path. Although I don't know for sure because I don't understand all those settings and the restrictions of each in regards to batch files.

 

Now I have another one I'm trying today and it doesn't seem to run. This one is to uninstall Office 2010 and to install Office 2013 (365). The batch works fine in our testing when we run it manually. Once again, my ccm package doesn't seem to work. Here is the batch file...

 

---------------------

setlocal
:DeployOffice
call cscript \\servername\pkg\office365\OffScrub10.vbs ProPlus /bypass 1 /q /s /NoCancel
start /wait \\servername\pkg\office365\setup.exe /configure \\servername\pkg\office365\proplus.xml
:End
Endlocal
---------------------
Everyone has access to the server. The execmgr.log doesn't offer much help... I don't see anything that looks like an error, but I do see it calling for the package.
Any suggestions on how I should set this one up? Run from distribution? Run locally? UNC or drive letter needed?
Thanks,
Doug

Share this post


Link to post
Share on other sites

Hi,

 

Is there any reason you don't want to allow the content to cache down to each machine?

 

It's been years since I looked at 2007 but I would always set 'this package contains source files' and browse to the directory that contains the setup files, then distribute the content to DPs. This will then cache the package down to each machine and run it locally when you target a device.. No server access headache issues, and it's the way Configuration Manager is designed to run. It's all via bits so should be fine.

 

99.99999999999 % of the time I go with a standard program.

Run = hidden

weather or not a user is logged on.

runs with a UNC name

 

for office though I would set to run only when no user is logged on.

If the user is running office it will fail or a user might try and look for office while it's in the process of installing \ removing.

 

I would create 2 or 3 separate programs for this.

 

1 cscript.exe OffScrub10.vbs ProPlus /bypass 1 /q /s /NoCancel

 

2 setup.exe /configure \\server\share\office365\proplus.xml

 

I rolled out this change sometime last year and found 20 % of the devices failed to run the scrub properly. So I had the full content for office 2010 cache down locally set to fully remove the product, then it ran the office scrub, then it ran a 3rd program to install the new office, each was set to reboot the machine after.

 

Each was chained via the program advanced tab, run other program first without the 'Always run this program first' checked (as you only want it to run once and not every time that program runs)

Share this post


Link to post
Share on other sites

Hey all,

I've been working on this all day and I still can't get it to run. I have changed it to run locally instead of from the dp. I moved the batch file to the folder containing all the contents. Here is a look at the folder...

 

post-29990-0-66440900-1453756823.jpg

 

You can ignore the "Batch for SCCM" folder as that was my testing folder for awhile. I'm now trying to run sccm_remove2010_install_2013.bat. The contents are...

 

echo

cd %~dp0

setlocal

:DeployOffice

call cscript OffScrub10.vbs ProPlus /bypass 1 /q /s /NoCancel

start /wait setup.exe /configure proplus.xml

:End

Endlocal

 

 

When I manually run this from c:\windows\syswow64\ccm\cached\packagefolder, it runs fine. However, I cannot get SCCM to run it.

 

When I run it manually it changes the directory to the package folder located in c:\windows\syswow64\ccm\cached so it is able to run the files in the batch. I cannot figure out for the life of me why it doesn't run in SCCM... and I've looked at execmgr.log and it appears to call it fine, but nothing ever happens on the machine.

 

Any ideas?

 

Thanks,

Doug

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.