Solved

Script to Remove Program from Startup/Logon

Posted on 2015-02-19
9
65 Views
Last Modified: 2015-03-18
Hello, what's the best approach to remove a program that automatically starts during logon? It resides locally in C:\Program Files (x86)\XXXXX.  Is there a script I can utilize? Ideally, I'd like to push it out using GPO.

Thank you!

J
0
Comment
Question by:Ja Che
  • 5
  • 4
9 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 40620514
If the program starts at Logon, it is (most commonly) either a shortcut in one of the following locations:
%APPDATA%\Microsoft\Windows\Start Menu\Programs\StartUp
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\<nameofprogram>
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\<nameofprogram>

Check which of those it is in, then remove it with a startup or logon script.

Regards,

Rob.
0
 

Author Comment

by:Ja Che
ID: 40621631
Hi Rob, thanks for the response. I checked each location and the program resides in C:\programdata\microsoft\windows\start menu\programs\StartUp.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40622582
OK no problem.  As a StartUp script you should be able to run this VBS:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\YourLink.lnk", True

Open in new window


Regards,

Rob.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 65

Expert Comment

by:RobSampson
ID: 40622586
You can also use Group Policy Preferences to delete the shortcut from that folder as well.

Rob.
0
 

Author Comment

by:Ja Che
ID: 40636212
Rob that was extremely helpful and works well. 1 question, though.

If the program has already been removed from startup, how can it be specified to ignore the file?

I receive a WSH runtime error saying "File not found". Attached is the error.

Thank you.
WSH-Error.JPG
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40636550
Hi, that will just be a matter of checking whether the file exists before attempting to delete it.

strFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\YourLink.lnk"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then objFSO.DeleteFile strFile, True

Open in new window


Rob.
0
 

Author Closing Comment

by:Ja Che
ID: 40640682
Thanks, Rob. Quick and helpful!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 40640699
No problem. Thanks for the grade.

Rob.
0
 

Author Comment

by:Ja Che
ID: 40674189
You're welcome.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question