Question

Change script to work as a startup script rather than a txt file.

Asked by: bsharath

Hi,

Change script to work as a startup script rather than a txt file.
Instead of Psexec and a txt file of systems i want it to work on invividual systems so can be used as a login script. And a log file that records the machines its found and date and machine name that its uninstalled.

Regards
Sharath

SETLOCAL ENABLEDELAYEDEXPANSION
Set Drives=c,d,e
Set LogFile=E:\VLCUninstall.log
Set Service=SAVService
 
for /f %%a in (computers16.txt) do (
    Set LogStatus=
    ECHO %%a
    for %%d in (%Drives%) do if exist "\\%%a\%%d$" for /f "tokens=*" %%f in ('dir /s /ad /b "\\%%a\%%d$\vlc"') DO if exist "%%f\Uninstall.exe" (
        Set FileFound=%%f\Uninstall.exe
        Set LocalFile=!FileFound:\\%%a\=!
        Set LocalFile=!LocalFile:$=:!
 
        Set LogStatus=%%a : VLC Uninstall.exe found "!LocalFile!"
        Set ServiceCounter=10
        sc \\%%a stop %service%
 
        Set ServiceOK=
        for /l %%z in (1,1,10) do if not defined ServiceOK sc \\%%a query %service% | Find /i "State" | Find /i "STOPPED" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
        if not defined ServiceOK (
            Set LogStatus=!LogStatus! : %service% did not stop
        ) Else (
            Set LogStatus=!LogStatus! : %service% stopped
 
            psexec \\%%a "!LocalFile!" /x /S /v/qn
            if errorlevel 1 (
                Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
            ) else (
                Set LogStatus=!LogStatus! : File executed "!LocalFile!"
            )
 
            sc \\%%a start %service%
 
            Set ServiceOK=
            for /l %%z in (1,1,10) do if not defined ServiceOK sc \\%%a query %service% | Find /i "State" | Find /i "RUNNING" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
            if not defined ServiceOK (
                Set LogStatus=!LogStatus! : %service% did not start
            ) Else (
                Set LogStatus=!LogStatus! : %service% running
            )
        )
    )
 
    if not defined LogStatus Set LogStatus=%%a : VLC Uninstall.exe not found
 
    ECHO !LogStatus!>>%LogFile%"
)

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-26 at 00:26:22ID24842764
Tags

Script

,

Bat

,

vbs

Topics

Programming Languages

,

Scripting Languages

,

Windows Batch Scripting

Participating Experts
2
Points
500
Comments
71

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Can i run Psexec like this.
    Hi, Can i run Psexec like this. psexec @computers.txt Filename.bat I want to run the bat files on all machines in the txt file Regards Sharath
  2. Uninstall Winrar remotely Via a script on a set of computer n…
    Hi, Uninstall Winrar remotely Via a script on a set of computer names in a txt file. I want help with a script that can uninstall Winrar on all machines in a txt file. Regards Sharath
  3. Using PSExec to deploy scripts
    Hi Guys I need some help to deploy a few .vbs scripts into multiple PCs remotely using psexec. is there a way i could do that? all my users do not have administrative rights. Cheers Manfred
  4. Change this vbs that reads a txt file of machines and runs a…
    Hi, Change this vbs that reads a txt file of machines and runs as a Startup script. Instead of a txt file i want a way to run as a startup script. remove all users/Groups and add just "System" into the SophosAdministrator group. Regards Sharath
  5. Startup script that can get the hardware details of a machin…
    Hi, Startup script that can get the hardware details of a machine and store in seperate txt files with machinename and date. On each startup the txt files should be created newly not overitten. So when some hardware is missing or changed. I know which date and between what t...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: sirbountyPosted on 2009-10-26 at 04:31:28ID: 25661175

Here it is, though not sure it will work as a logon script, unless your users are admins...

SETLOCAL ENABLEDELAYEDEXPANSION
Set Drives=c,d,e
Set LogFile=E:\VLCUninstall.log
Set Service=SAVService
Set LogStatus=
 
for %%d in (%Drives%) do if exist "%%d:" for /f "tokens=*" %%f in ('dir /s /ad /b "%%d$\vlc"') DO if exist "%%f\Uninstall.exe" (
        Set FileFound=%%f\Uninstall.exe
        Set LocalFile=!FileFound!
 
        Set LogStatus=%ComputerName% : VLC Uninstall.exe found "!LocalFile!"
        Set ServiceCounter=10
        sc stop %service%
 
        Set ServiceOK=
        for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "STOPPED" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
        if not defined ServiceOK (
            Set LogStatus=!LogStatus! : %service% did not stop
        ) Else (
            Set LogStatus=!LogStatus! : %service% stopped
 
            Start "!LocalFile!" /x /S /v/qn
            if errorlevel 1 (
                Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
            ) else (
                Set LogStatus=!LogStatus! : File executed "!LocalFile!"
            )
 
            sc start %service%
 
            Set ServiceOK=
            for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "RUNNING" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
            if not defined ServiceOK (
                Set LogStatus=!LogStatus! : %service% did not start
            ) Else (
                Set LogStatus=!LogStatus! : %service% running
            )
        )
    )
 
    if not defined LogStatus Set LogStatus=%ComputerName% : VLC Uninstall.exe not found
 
    ECHO !LogStatus!>>%LogFile%"
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-26 at 04:36:32ID: 25661200

Thank U
I need to get logs in a UNC path Like
Machinename Uninstalled VLC at 27-10-2009 10.00 PM

 

by: sirbountyPosted on 2009-10-26 at 04:49:17ID: 25661270

THen just change that last line:
ECHO !LogStatus!>>%LogFile%"
to
ECHO !LogStatus!>>\\Server\Share\%LogFile%"

 

by: bsharathPosted on 2009-10-26 at 07:11:28ID: 25662380

Should i comment this line?
Set LogFile=E:\VLCUninstall.log

 

by: sirbountyPosted on 2009-10-26 at 07:25:58ID: 25662542

Oh, no - you can change that to

Set LogFile=\\Server\Share\VLCUninstall.log
then change the above to
ECHO !LogStatus!>>%LogFile%"

 

by: bsharathPosted on 2009-10-26 at 07:53:08ID: 25662805

You mean dont change the first change..>Can i have the full code please

 

by: sirbountyPosted on 2009-10-26 at 08:28:27ID: 25663231

SETLOCAL ENABLEDELAYEDEXPANSION
Set Drives=c,d,e
Set LogFile=\\Server\Share\VLCUninstall.log
Set Service=SAVService
Set LogStatus=
 
for %%d in (%Drives%) do if exist "%%d:" for /f "tokens=*" %%f in ('dir /s /ad /b "%%d$\vlc"') DO if exist "%%f\Uninstall.exe" (
        Set FileFound=%%f\Uninstall.exe
        Set LocalFile=!FileFound!
 
        Set LogStatus=%ComputerName% : VLC Uninstall.exe found "!LocalFile!"
        Set ServiceCounter=10
        sc stop %service%
 
        Set ServiceOK=
        for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "STOPPED" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
        if not defined ServiceOK (
            Set LogStatus=!LogStatus! : %service% did not stop
        ) Else (
            Set LogStatus=!LogStatus! : %service% stopped
 
            Start "!LocalFile!" /x /S /v/qn
            if errorlevel 1 (
                Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
            ) else (
                Set LogStatus=!LogStatus! : File executed "!LocalFile!"
            )
 
            sc start %service%
 
            Set ServiceOK=
            for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "RUNNING" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
            if not defined ServiceOK (
                Set LogStatus=!LogStatus! : %service% did not start
            ) Else (
                Set LogStatus=!LogStatus! : %service% running
            )
        )
    )
 
    if not defined LogStatus Set LogStatus=%ComputerName% : VLC Uninstall.exe not found
 
    ECHO !LogStatus!>>%LogFile%"

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-26 at 08:31:04ID: 25663266

Will the service stop and then search for the file or if found then stop the service?

 

by: bsharathPosted on 2009-10-26 at 08:34:55ID: 25663310

I just tried and it did now uninstall
C:\Program Files\VideoLAN\VLC
the above location had the uninstall but in the log it says not found

 

by: bsharathPosted on 2009-10-26 at 09:49:17ID: 25664176

Please see below it fails to uninstall

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
 
D:\>Uninstall_VLC.bat
 
D:\>SETLOCAL ENABLEDELAYEDEXPANSION
 
D:\>Set Drives=c,d,e
 
D:\>Set LogFile=\\Sophos\InterChk\VLCUninstall.log
 
D:\>Set Service=SAVService
 
D:\>Set LogStatus=
 
D:\>for %d in (c d e) do if exist "%d:" for /F "tokens=*" %f in ('dir /s /ad /b
"%d$\vlc"') DO if exist "%f\Uninstall.exe" (
Set FileFound=%f\Uninstall.exe
 Set LocalFile=!FileFound!
 Set LogStatus=Pc0306 : VLC Uninstall.exe found "!LocalFile!"
 Set ServiceCounter=10
 sc stop SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "STOPPED"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not stop )
  Else (
Set LogStatus=!LogStatus! : SAVService stopped
 Start "!LocalFile!" /x /S /v/qn
 if errorlevel 1 (Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
 )  else (Set LogStatus=!LogStatus! : File executed "!LocalFile!" )
 sc start SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "RUNNING"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not start
)  Else (Set LogStatus=!LogStatus! : SAVService running )
)
)
 
D:\>if exist "c:" for /F "tokens=*" %f in ('dir /s /ad /b "c$\vlc"') DO if exist
 "%f\Uninstall.exe" (
Set FileFound=%f\Uninstall.exe
 Set LocalFile=!FileFound!
 Set LogStatus=Pc0306 : VLC Uninstall.exe found "!LocalFile!"
 Set ServiceCounter=10
 sc stop SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "STOPPED"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not stop )
  Else (
Set LogStatus=!LogStatus! : SAVService stopped
 Start "!LocalFile!" /x /S /v/qn
 if errorlevel 1 (Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
 )  else (Set LogStatus=!LogStatus! : File executed "!LocalFile!" )
 sc start SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "RUNNING"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not start
)  Else (Set LogStatus=!LogStatus! : SAVService running )
)
)
The system cannot find the file specified.
 
D:\>if exist "d:" for /F "tokens=*" %f in ('dir /s /ad /b "d$\vlc"') DO if exist
 "%f\Uninstall.exe" (
Set FileFound=%f\Uninstall.exe
 Set LocalFile=!FileFound!
 Set LogStatus=Pc0306 : VLC Uninstall.exe found "!LocalFile!"
 Set ServiceCounter=10
 sc stop SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "STOPPED"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not stop )
  Else (
Set LogStatus=!LogStatus! : SAVService stopped
 Start "!LocalFile!" /x /S /v/qn
 if errorlevel 1 (Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
 )  else (Set LogStatus=!LogStatus! : File executed "!LocalFile!" )
 sc start SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "RUNNING"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not start
)  Else (Set LogStatus=!LogStatus! : SAVService running )
)
)
The system cannot find the file specified.
 
D:\>if exist "e:" for /F "tokens=*" %f in ('dir /s /ad /b "e$\vlc"') DO if exist
 "%f\Uninstall.exe" (
Set FileFound=%f\Uninstall.exe
 Set LocalFile=!FileFound!
 Set LogStatus=Pc0306 : VLC Uninstall.exe found "!LocalFile!"
 Set ServiceCounter=10
 sc stop SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "STOPPED"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not stop )
  Else (
Set LogStatus=!LogStatus! : SAVService stopped
 Start "!LocalFile!" /x /S /v/qn
 if errorlevel 1 (Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
 )  else (Set LogStatus=!LogStatus! : File executed "!LocalFile!" )
 sc start SAVService
 Set ServiceOK=
 for /L %z in (1 1 10) do if not defined ServiceOK sc query SAVService   | Find
/i "State"   | Find /i "RUNNING"   & if not errorlevel 1 (Set ServiceOK=Done )
else (Ping 127.0.0.1 -n 5 -w 1000  1>Nul )
 if not defined ServiceOK (Set LogStatus=!LogStatus! : SAVService did not start
)  Else (Set LogStatus=!LogStatus! : SAVService running )
)
)
 
D:\>if not defined LogStatus Set LogStatus=Pc0306 : VLC Uninstall.exe n
ot found
 
D:\>ECHO !LogStatus! 1>>\\sophos\InterChk\VLCUninstall.log"

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-28 at 07:24:12ID: 25683529

Any views

 

by: JeffPartonPosted on 2009-11-02 at 21:47:59ID: 25726331

Let me study this a little more when at my main machine, i am on my laptop now and it doesn't have my normal tools.  But I will help.  I use scripts to uninstall software all the time in my network.  So I believe I can help you out.  There are ways to use script to runas an administrator or someone with authorities to uninstall.

 

by: JeffPartonPosted on 2009-11-03 at 10:39:06ID: 25731983

Curious, if you through command prompt cd to the directory where the uninstall is located.  If you type:

uninstall /?

Are there any hidden flags that can be used with the uninstall.exe??

 

by: bsharathPosted on 2009-11-03 at 10:43:43ID: 25732023

When i try uninstall /?
It starts uninstalling

 

by: JeffPartonPosted on 2009-11-03 at 11:01:47ID: 25732248

ok so no flags, just wanted to check.  Sometimes setup.exe files have hidden flags to install quietly, etc.
didn't know if the uninstall had any either.

 

by: sirbountyPosted on 2009-11-04 at 05:01:41ID: 25738827

Sorry Sharath, got pulled away on something - try this modification:
If it doesn't work (or maybe even if it does), I'd suggest another route here - perhaps using vbscript if there's no other automated solution.
The processing of this thing is potentially exceptionally lengthy - this code scans an entire drive before proceeding to uninstall?  I'd imagine folks would complain sooner or later...

SETLOCAL ENABLEDELAYEDEXPANSION
Set Drives=c,d,e
Set LogFile=\\Server\Share\VLCUninstall.log
Set Service=SAVService
Set LogStatus=
 
for %%d in (%Drives%) do if exist "%%d:\" for /f "tokens=*" %%f in ('dir /s /ad /b "%%d$\vlc"') DO if exist "%%f\Uninstall.exe" (
        Set FileFound=%%f\Uninstall.exe
        Set LocalFile=!FileFound!
 
        Set LogStatus=%ComputerName% : VLC Uninstall.exe found "!LocalFile!"
        Set ServiceCounter=10
        sc stop %service%
 
        Set ServiceOK=
        for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "STOPPED" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
        if not defined ServiceOK (
            Set LogStatus=!LogStatus! : %service% did not stop
        ) Else (
            Set LogStatus=!LogStatus! : %service% stopped
 
            Start "!LocalFile!" /x /S /v/qn
            if errorlevel 1 (
                Set LogStatus=!LogStatus! : Error executing File "!LocalFile!"
            ) else (
                Set LogStatus=!LogStatus! : File executed "!LocalFile!"
            )
 
            sc start %service%
 
            Set ServiceOK=
            for /l %%z in (1,1,10) do if not defined ServiceOK sc query %service% | Find /i "State" | Find /i "RUNNING" & if not errorlevel 1 (Set ServiceOK=Done) else (Ping 127.0.0.1 -n 5 -w 1000 > Nul)
 
            if not defined ServiceOK (
                Set LogStatus=!LogStatus! : %service% did not start
            ) Else (
                Set LogStatus=!LogStatus! : %service% running
            )
        )
    )
 
    if not defined LogStatus Set LogStatus=%ComputerName% : VLC Uninstall.exe not found
 
    ECHO !LogStatus!>>%LogFile%"

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-04 at 06:32:55ID: 25739617

Yes a vbs if faster would be great
I get this in the log
DE0306 : VLC Uninstall.exe not found
But still the vlc is there
C:\Program Files\VideoLAN\VLC

 

by: bsharathPosted on 2009-11-18 at 08:56:52ID: 25851775

Any views...

 

by: JeffPartonPosted on 2009-11-18 at 17:22:47ID: 25856821

I would like to try a different perspective if I may.

You mentioned that a machine, in the log, shows NO uninstall.  But you say that the machine has the file at:

C:\Program Files\VideoLAN\VLC

Is the actual path to the uninstall on this machine

C:\Program Files\VideoLAN\VLC\uninstall.exe     ?

If so, please search this paticular machines registry for this string.

Basically, I am trying to find where under hklm is the Uninstallstring found.

If you could find the registry path to the key that holds this path on this machine I may be able to help.

 

by: JeffPartonPosted on 2009-11-18 at 17:23:49ID: 25856828

If you don't know how to search the registry to find where this string is found, let me know.

 

by: JeffPartonPosted on 2009-11-18 at 17:27:33ID: 25856842

Most likely it will be found somewhere in

hkey_local_machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\

In there you should find a folder that correlates to the software name.

I need to know this subkey.  Inside this subkey, you should find a key named "UninstallString" in the right pane.  The value for that key should be the "path to the uninstall.exe" for the software.

 

by: bsharathPosted on 2009-11-18 at 19:48:00ID: 25857358

Jeff attached is the registry image.

Please see the bottom for the path you mentioned.

 

by: JeffPartonPosted on 2009-11-19 at 21:22:43ID: 25867809

Try this for the uninstall.  I did NOT mess with the service status or starting or stopping the service.  If this is required I can add it easily.  Just ran out of time here.

Here is a script to try.  It should find the Uninstall wherever it may be on the local machine and uninstall it.  Since earlier you posted that the Uninstall didn't have any flags I am not sure if it will uninstall silently without user input or not.

Try it and let me know.  I am NOT able to test this, so there may be a syntax error somewhere I may have missed.

On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\Server\Share\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	objFile.WriteLine(Date() & "/" & Time() & " - " & CName & "/" & UName & " chose NO to install software.")
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
					arrValueNames(i),strValue
				UninstallStringToUse = strValue
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	WshShell.Run UninstallStringToUse
	Err.Clear
	if  Err.Number <> 0  then   
		objFile.WriteLine("ERROR:  Uninstall found at : " & UninstallStringToUse & " -- " & CName & " failed to initiate the VLC Uninstall.  Error number : " & Err.Number & "    Error description: '" & Err.Description & "'"
	else
		objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:

Select allOpen in new window

 

by: JeffPartonPosted on 2009-11-19 at 21:25:18ID: 25867815

Oh no forgot to delete a line.  I use this script myself so forgot to delete one line.  

Delete the line:

objFile.WriteLine(Date() & "/" & Time() & " - " & CName & "/" & UName & " chose NO to install software.")
      

 

by: bsharathPosted on 2009-11-19 at 21:27:50ID: 25867821

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\Shar\Desktop\Vlc.vbs
Line:      53
Char:      218
Error:      Expected ')'
Code:      800A03EE
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-19 at 21:31:37ID: 25867831

I forgot one more thing.  A mistake I just found

Change:

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames(i),strValue

To

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue

on line 40 and 41 (What I said to change shows 1 line above, in the script the line is split into two)  Just make sure that the total statement shows this change.

 

by: JeffPartonPosted on 2009-11-19 at 21:33:59ID: 25867841

objFile.WriteLine("ERROR:  Uninstall found at : " & UninstallStringToUse & " -- " & CName & " failed to initiate the VLC Uninstall.  Error number : " & Err.Number & "    Error description: '" & Err.Description & "'"

I forgot to put a ")" at the end of the statement.

Make it

objFile.WriteLine("ERROR:  Uninstall found at : " & UninstallStringToUse & " -- " & CName & " failed to initiate the VLC Uninstall.  Error number : " & Err.Number & "    Error description: '" & Err.Description & "'")

Please make sure you make the other changes I said, or the script WON'T work.  It would read the WRONG key.
            

 

by: bsharathPosted on 2009-11-19 at 21:37:44ID: 25867855

I did the last 2 changes also. I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\SharathR\Desktop\Vlc.vbs
Line:      60
Char:      1
Error:      Expected 'End'
Code:      800A03F6
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-19 at 21:44:04ID: 25867870

On line 57 BEFORE the line

objFile.Close

ADD

End If

 

by: JeffPartonPosted on 2009-11-19 at 21:44:50ID: 25867872

And SAVE it, of course lol :)

 

by: bsharathPosted on 2009-11-19 at 22:39:25ID: 25868020

It did run without error...
But Does not uninstall

 

by: JeffPartonPosted on 2009-11-20 at 07:05:47ID: 25870967

Does the log show that the Uninstall initialized or does it show ERROR?

 

by: bsharathPosted on 2009-11-20 at 10:01:46ID: 25872769

I get this

Uninstall found at : C:\Program Files\VideoLAN\VLC\uninstall.exe -- DEV306 initiated the Uninstall for VLC at 20-11-2009 at 10:28:04 PM.

I think some silent switches are missing..Not sure

 

by: JeffPartonPosted on 2009-11-20 at 10:08:52ID: 25872840

If you remember from a previous post I had you do the uninstall.exe /?

usually this will show any switches.  In all honesty most switches are in the actual SETUP.exe for the program.

you can see if you do a setup.exe /?  from a dos prompt for the original install setup.

Most times there is a /u  /s  switches where /u = uninstall  and /s = Silent

if that is what the log reads then the exe was initiated.

You can remove the On error resume next at the beginning and rerun.  If there is an error it will prompt.  Could be a permissions issue too.

 

by: JeffPartonPosted on 2009-11-20 at 10:11:10ID: 25872858

You could also open your Task Manager and watch the Processes (I would sort them by clicking on the heading).  Run the script with the Task Manager up.  This will also tell you if the uninstall.exe was started.  The logon script has no way of knowing if the uninstall was SUCCESSFUL or not since it doesn't monitor windows events for success or failure.  You can also check your Event Viewer logs and see if you can find where the failure occurred.

 

by: JeffPartonPosted on 2009-11-20 at 10:13:27ID: 25872876

You could also search online or call software vendor to see if there are any switches.  If so, would be easy to implement in script.

 

by: bsharathPosted on 2009-11-20 at 10:14:56ID: 25872891

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\SharathR\Desktop\Vlc.vbs
Line:      49
Char:      2
Error:      The system cannot find the file specified.
Code:      80070002
Source:       (null)

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-20 at 10:20:54ID: 25872944

Hmm, that number doesn't match my above script with what i expected.  If it is the line

WshShell.Run UninstallStringToUse

Then change on around Line 42

UninstallStringToUse = strValue

To

UninstallStringToUse = Cstr(strValue)

maybe for some odd reason a string value from registry when querying makes it a variant and not string.  if you make this change then script will convert whatever it is to String.  Then retry.



 

by: bsharathPosted on 2009-11-20 at 10:23:41ID: 25872980

I get this
---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\Shar\Desktop\Vlc.vbs
Line:      50
Char:      2
Error:      The system cannot find the file specified.
Code:      80070002
Source:       (null)

---------------------------
OK  
---------------------------

Below is the code


Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				UninstallStringToUse = Cstr(strValue)
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	WshShell.Run UninstallStringToUse
	Err.Clear
	if  Err.Number <> 0  then   
		objFile.WriteLine("ERROR:  Uninstall found at : " & UninstallStringToUse & " -- " & CName & " failed to initiate the VLC Uninstall.  Error number : " & Err.Number & "    Error description: '" & Err.Description & "'")
 
	else
		objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	end if
 	end if
 
objFile.Close 
set objFile = Nothing
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:

Select allOpen in new window

 

by: JeffPartonPosted on 2009-11-20 at 11:13:47ID: 25873453

ohhh, hehe, my bad without the

on error resume next

the err won't exist.  I feel rather stupid lol.

Add a line BEFORE line 50 right before the err.clear

on error resume next

 

by: bsharathPosted on 2009-11-20 at 11:22:14ID: 25873539

Still get the same exact error

 

by: JeffPartonPosted on 2009-11-20 at 11:42:38ID: 25873737

Ok another new approach.  Same basic script with a different approach for the running of the install.

Try this:

Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				UninstallStringToUse = strValue
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	Set objWMIService = GetObject("winmgmts:" _
		& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
	Set colSoftware = objWMIService.ExecQuery _
		("Select * from Win32_Product Where Name = 'VLC media player'")
 
	For Each objSoftware in colSoftware
		objSoftware.Uninstall()
	Next
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-20 at 11:48:53ID: 25873808

Sttill no luck..
The code in my question does work...Are the same uninstall switches used in this changed code too.

 

by: JeffPartonPosted on 2009-11-20 at 11:49:54ID: 25873829

Won't work with Vista, Windows 7, or Windows 2008

I know a lot of posts but try the below with edited code.

on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				UninstallStringToUse = Cstr(strValue)
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	WshShell.Run(UninstallStringToUse, 1, True)
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-20 at 11:51:52ID: 25873847

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\SharathR\Desktop\Vlc.vbs
Line:      51
Char:      45
Error:      Cannot use parentheses when calling a Sub
Code:      800A0414
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-20 at 11:54:48ID: 25873880

Ok found some uninstall switches.

Try this, again sorry for so many posts.

on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				strValue = strValue & " /S /NCRC"
				UninstallStringToUse = Cstr(strValue)
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	WshShell.Run(UninstallStringToUse, 1, True)
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:

Select allOpen in new window

 

by: JeffPartonPosted on 2009-11-20 at 11:56:23ID: 25873897

Change

WshShell.Run(UninstallStringToUse, 1, True)

To

WshShell.Run UninstallStringToUse

 

by: JeffPartonPosted on 2009-11-20 at 12:04:22ID: 25873983

I was under the impression that the code in your original question (the BAT file) was unacceptable since it took a VERY long time to execute.

That is the only reason i was trying to do it in vbscript using the registry.  When the program is installed the registry entry is created.  It will have the location of the uninstall file in that key, REGARDLESS of what local drive it was installed on.  For this reason, a "search" of all the local drives BEFORE executing the uninstall is not necessary.

If this is not the case, then I will stop trying to update the script.

and yes, the flags will be the same regardless of how you invoke the install.

 

by: bsharathPosted on 2009-11-20 at 12:04:31ID: 25873984

Still does not uninstall
But when i run this manually it uninstalls perfectly
C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC

 

by: bsharathPosted on 2009-11-20 at 12:07:37ID: 25874018

yes thats exactly what i want
Can we try this path. If not found then search the other parts.
By default its this path. say 10 out of 100 install it in some other paths
C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC

 

by: JeffPartonPosted on 2009-11-20 at 12:08:00ID: 25874020

If in your bat file if you want to change the bat file to pull in the registry entry and use those flags then it should work for you.

I don't know how to work with BAT files.

If the script is not installing then the string for the uninstall build isn't being passed correctly.

 

by: JeffPartonPosted on 2009-11-20 at 12:14:01ID: 25874088

Ok Try this, added the default string

on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				if Cstr(strValue) = "C:\Program Files\VideoLAN\VLC\uninstall.exe" then
					DefaultUninstall = 1
				else
					DefaultUninstall = 0
				end if
				strValue2 = Cstr(strValue) & " /S /NCRC"
				UninstallStringToUse = Cstr(strValue2)
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	if DefaultUninstall = 1 then
		WshShell.Run("C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC", 1, True)
	else
		WshShell.Run UninstallStringToUse
	end if
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-20 at 12:16:49ID: 25874116

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Users\Sharat\Desktop\Vlc.vbs
Line:      57
Char:      80
Error:      Cannot use parentheses when calling a Sub
Code:      800A0414
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-20 at 12:24:01ID: 25874167

Change to:

WshShell.Run "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC"

 

by: JeffPartonPosted on 2009-11-20 at 12:26:13ID: 25874185

I think another change: keep track of the "old" value just in case

Change

strValue2 = Cstr(strValue) & " /S /NCRC"


To

strValue2 = """" & Cstr(strValue) & " /S /NCRC" & """"

 

by: bsharathPosted on 2009-11-20 at 12:28:57ID: 25874212

Is change this to this
WshShell.Run("C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC", 1, True)
To

WshShell.Run "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC"

 

by: JeffPartonPosted on 2009-11-20 at 12:31:09ID: 25874230

Yes

 

by: JeffPartonPosted on 2009-11-20 at 12:40:37ID: 25874315

with all the changes i will post the complete script again with the changes

on error resume next
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
ServiceToCheck = "SAVService" 
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				if Cstr(strValue) = "C:\Program Files\VideoLAN\VLC\uninstall.exe" then
					DefaultUninstall = 1
				else
					DefaultUninstall = 0
				end if
				strValue2 = Cstr(strValue) & " /S /NCRC"
				UninstallStringToUse = Cstr(strValue2)
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	if DefaultUninstall = 1 then
		WshShell.Run "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC", 1, True
	else
		WshShell.Run UninstallStringToUse, 1, True
	end if
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-20 at 12:40:49ID: 25874319

still does not work

 

by: JeffPartonPosted on 2009-11-20 at 12:53:27ID: 25874453

Out of curiosity.

Add the line

msgbox "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC" & " - Compared to - " & UninstallStringToUse

AFTER the line that reads

If StringExists = 1 then

Do they match??

 

by: bsharathPosted on 2009-11-20 at 12:55:57ID: 25874472

I get this

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

---------------------------
C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC - Compared to -
C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC
---------------------------
OK  
---------------------------

 

by: bsharathPosted on 2009-11-20 at 12:59:50ID: 25874503

When i run this line manually it does uninstall
C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC

 

by: JeffPartonPosted on 2009-11-20 at 13:04:58ID: 25874532

One more test please.

Change

msgbox "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC" & " - Compared to - " & UninstallStringToUse

To

msgbox "C:\Program Files\VideoLAN\VLC\uninstall.exe /S /NCRC" & " - Compared to - " & """" & UninstallStringToUse & """"

 

by: JeffPartonPosted on 2009-11-20 at 13:26:13ID: 25874695

If you could please.  On about line 47

UninstallStringToUse = Cstr(strValue2)

Change this to

UninstallStringToUse = """" & strValue2 & """"

I am curious if this runs.  For some reason it is not seeing the variable correctly.

 

by: JeffPartonPosted on 2009-11-20 at 13:51:52ID: 25874875

Solved it.  I actually installed the silly program for testing.  It works on my machine with the below script.

It does NOT do the Default thing.  This version finds it wherever it is and uninstalls silently.  I test on multiple local drive letters and all worked.

Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
 
strComputer = "."
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell") 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objNet = CreateObject("WScript.NetWork") 
CName = objNet.ComputerName
Set objNet = Nothing 
strKeyPath = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall"
strKeyPath2 = "SOFTWARE\MIcrosoft\Windows\CurrentVersion\Uninstall\VLC media player"
LogFileResults = "\\in-ict-dsm\logs\VLCUninstall.log"
 
If objFSO.FileExists(LogFileResults) Then
	Set objFile = objFSO.OpenTextFile(LogFileResults, ForAppending, True)
Else
	Set objFile = objFSO.CreateTextFile(LogFileResults)
End If
	
	
	
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
SubkeyExists = 0 
For Each subkey In arrSubKeys
    if subkey = "VLC media player" then
		SubkeyExists = 1
	end if
	if SubkeyExists = 1 then
		oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath2,_
			arrValueNames, arrValueTypes
		StringExists = 0
		For i=0 To UBound(arrValueNames)
			if arrValueNames(i) = "UninstallString" then
				StringExists = 1
				oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath2,arrValueNames(i),strValue
				strValue2 = Cstr(strValue) & " /S /NCRC"
				UninstallStringToUse = strValue2
 
			end if
		Next
		SubkeyExists = 0
	end if
next
 
If StringExists = 1 then
	WshShell.Exec UninstallStringToUse
	objFile.WriteLine("Uninstall found at : " & UninstallStringToUse & " -- " & Cname & " initiated the Uninstall for VLC at " & Day(Date()) & "-" & Month(Date()) & "-" & Year(Date()) & " at " & Time() & ".")
	
end if
 
objFile.Close 
set objFile = Nothing

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-21 at 00:39:19ID: 25877009

Thanks for this patient help..
I get this

---------------------------
Windows Script Host
---------------------------
Script:      D:\Vlc.vbs
Line:      49
Char:      2
Error:      The requested operation requires elevation.

Code:      800702E4
Source:       WshShell.Exec

---------------------------
OK  
---------------------------

 

by: JeffPartonPosted on 2009-11-21 at 10:09:35ID: 25878834

Try to Change

WshShell.Exec UninstallStringToUse


UninstallStringToUse = "runas /user:administator " & UninstallStringToUse
WshShell.Exec UninstallStringToUse


Replace the one line with the two lines.  This is just a try.  I had assumed that the permissions were in place.  This may NOT work.  If not, we can try something else.

 

by: JeffPartonPosted on 2009-11-21 at 10:10:20ID: 25878839

Secondary Logon    Service must be started for this though.

 

by: bsharathPosted on 2009-11-21 at 10:23:09ID: 25878903

Thanks a lot Jeffparton

 

by: JeffPartonPosted on 2009-11-23 at 09:47:09ID: 25889740

Curious, did the "runas" part i posted

UninstallStringToUse = "runas /user:administator " & UninstallStringToUse
WshShell.Exec UninstallStringToUse

Did it work for you?  If not, you may want to test a machine directly with login script.  If I am not mistaken, the login script being sent from the AD will run as administrator instead of from the local users permission levels.  I think it would run as System.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...