There are some programs which do not install to the "Program Files" directory on computers. Some programs like "Spotify" for this example, install under the users appdata\roaming folder. For this, an uninstall is not possible by typical uninstall scripts. For this, I would use a batch file to kill the processes it uses and delete the AppData Folder.
This process can be replicated for other such folders or if you want to remove a specific folder from the user.
First things first:
These instructions are for Windows 7 computers. All variables may change based on other OSes.
Identify the processes you will need to kill incase your user is using it at the moment you run the script. For our demo, we are going to go over Spotify. Spotify uses 2 processes: "spotify.exe" and "spotifywebhelper.exe". Hang onto these for your script later.
Next we identify the subfolder that the program has installed itself. In the case of spotify it's C:\users\username\appdata\roaming\spotify. In short it will be the "%appdata%\spotify" variable. You will also need this for your script, so keep that in mind as well.
Now to the meat of things. We want to use the scripting interface to accomplish this task.
- Go to the scripting tab and add a new, "Online KScript", Give it a name and any other fields you want to fill out.
- Choose the computer(s) you would like to run this on. Smart lables come in handy here.
- Choose the OS Versions you would like to run this on
- Run as User Logged in to console
- This is important as the %appdata% variable will only work under this context
- Choose your schedule
- Task Creation Section
- Choose your max attempts
- On failure Break or Continue, your choice. I usually continue for testing purposes
- Verify if the directory you want exists, in this demo it's %appdata%\spotify (note %appdata% leads to "c:\users\username\appdata\roaming" so there is no need to add \roaming
- On Success
- If you want for testing and logging, add a status message such as Spotify Found (optional)
- Run a batch file
- Name the script
- taskkill /f /im spotify.exe (or your other product noted prior)
- taskkill /f /im spotifywebhelper.exe (repeat for any other EXEs you need to kill)
- rmdir "%appdata%/Spotify" /s /q (this removes the entire spotify directory, replace with your product)
- del c:\users\%username%\desktop\spotify.lnk (this removes the shortcut on the users desktop)
- Click wait for completion to allow the batchfile to run
- Save changes
- Name the script
- Save the script and run now or wait for the schedule to happen
There you have it! Follow these instructions and tweak for your specific programs. Add other lines to remove other items left behind. This is just the basics of it. Below are some screenshots to give a visual on what it would look like in the K1000