Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: vbscript to unpin from task bar not working

13 Oct 2014   #1
Briandr

Windows 7 Professional x32 & x64
 
 
vbscript to unpin from task bar not working

Hi,

I can't get this vbscript to work. Any ideas?

Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Const CSIDL_STARTMENU = &HB
Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path

If objFSO.FileExists(strAllUsersProgramsPath & "\Programs\Windows Media Player.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName("Windows Media Player.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If

If objFSO.FileExists(strAllUsersProgramsPath & "\Programs\Google Chrome\Google Chrome.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath)
Set objFolderItem = objFolder.ParseName("Google Chrome.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt

Next
End If

Thanks.


My System SpecsSystem Spec
.
13 Oct 2014   #2
MilesAhead

Windows 7 32 bit
 
 

"Can't get it to work" is kind of vague. Firstly when you create objects from ActiveX you should check the return to see if an object was indeed created. Using error checking will give more clues what went wrong than me guessing.

If you get some error messages then post. But I think you'd have better luck on a vbs programming forum. Many more vbs aficionados would read it for one thing.
My System SpecsSystem Spec
13 Oct 2014   #3
Briandr

Windows 7 Professional x32 & x64
 
 

There were no error messages when it ran. Sorry for being vague.
My System SpecsSystem Spec
.

13 Oct 2014   #4
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by Briandr View Post
There were no error messages when it ran. Sorry for being vague.
Always check return values unless you are just posting example code meant to be fleshed out by others and need to save space. That's what return values are for. So you have a clue what happened.
My System SpecsSystem Spec
Reply

 vbscript to unpin from task bar not working




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Task scheduler not working?
I can't defrag, and can't schedule any tasks. These are screenshots of my error messages. What can I do about finding "remote computer"? I only have this one!
Performance & Maintenance
IE9 task not working.
On a website that I access frequently I am now having a problem when I try to click on a link on that site. Nothing happens. Some of the links do work however. I have accessed the site on another computer and it works fine. All other sites I visit work fine. Thanks in advance. Bob G.
Browsers & Mail
Task Scheduler not working
Hi I can not run task scheduler pops the message "can not find the remote computer" Help ! Ps. I also used WWDC http://img30.imageshack.us/img30/879/wwdc.th.jpg
General Discussion
Task Scheduler is not working!
Hi, I have a freeware program called CleanMem and it runs with task scheduler. With it's use from Vista it was fine but not with transition to windows 7 after a few weeks task scheduler succumbs to an error such as the image below. Please help with this problem, i'm on a Windows 7 Ultimate with...
BSOD Help and Support
Task Scheduler is not working!
Hi, I have a freeware program called CleanMem and it runs with task scheduler. With it's use from Vista it was fine but not with transition to windows 7 after a few weeks task scheduler succumbs to an error such as the image below. Please help with this problem, i'm on a Windows 7 Ultimate...
Software
Task Scheduler Not Working
Wanted to schedule back up, but got a notice task scheduler no longer exists, what should I do? Notice says no longer exists. System restore did not help
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 04:17.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App