Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with a "Pin-to-taskbar"-Script 1

Status
Not open for further replies.

CheckzenFiive

Technical User
Apr 28, 2011
16
DE
Hello there :- )


I´ve got a problem:

I´ve written a script that pins applications to the taskbar.

It looks like this:

___________________________________________________________________

on error resume next
Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
set ArgObj = wscript.Arguments

dim PfadEXE
dim PinModus
dim Sprache
dim DebugMode

Debugmode = 1
PfadEXE = argobj(0)
PinModus = argobj(1)
Sprache = argobj(2)

if DebugMode = 1 then
msgbox "-" & PfadEXE & "- -" & PinModus & "- -" & Sprache & "-"
end if


strlPath = PfadEXE
strFolder = objFSO.GetParentFolderName(strlPath)
strFile = objFSO.GetFileName(strlPath)
Set objFolder = objShell.Namespace(strFolder)
set objFolderItem = objFolder.ParseName(strFile)
Set colVerbs = objFolderItem.Verbs
For each itemverb in objFolderItem.verbs
if Sprache = 1 Then
if PinModus = 1 Then
If Replace(itemverb.name, "&", "") = "An Taskleiste anheften" Then itemverb.DoIt
end if
if PinModus = 0 Then
If Replace(itemverb.name, "&", "") = "Von Taskleiste lösen" Then itemverb.DoIt
end if
End if
if Sprache = 0 then
if PinModus = 1 then
If Replace(itemverb.name, "&", "") = "Pin to taskbar" Then itemverb.DoIt
End if
if PinModus = 0 then
If Replace(itemverb.name, "&", "") = "Unpin this program from taskbar" Then itemverb.DoIt
End if
end if
next
___________________________________________________________________



So the script works like this:

Open cmd.exe -> Insert Script -> Insert applicationpath -> 1 / 0 for pin or unpin -> 1 / 0 for german / english.

Example: "C:\Users\Desktop\pin.vbs" "C:\Windows\Explorer.exe" 1 1


My problem is that I want to pin the applications with arguments/parameters like "explorer.exe -e".


Does anyone have an idea how I can realize this?



Thanks in advance,


CheckzenFiive



 
Hello there again :- )

I´ve changed several things now after receiving errors.
Now it say´s "The object doesnt support 'objShell.CreateShortcut'.

I´ve googled for this but it seems like this is a correct code.
You´ve got any idea why the error pops up?


Cheers
Checkzen
 
The Shell.Application object does not have the .CreateShortcut method. Wscript.Shell does.

Code:
Set objShell = CreateObject("Shell.Application")

should be

Code:
Set objShell = CreateObject("Wscript.Shell")

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hmm.. can´t get it running anyways.
Would you mind to state the whole code again?

Since I don´t know, what´s going wrong.



Cheers
Checkzen
 
Are you running Windows XP or Windows 7?

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
In Win7, taskbar shortcuts are stored in C:\Users\username\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar. Unfortunately, items in this folder do not appear on the task bar if they were not added using the "Pin to Taskbar" verb of the folder's (..\Taskbar) namespace. Yet, the only way I know how to change the target is during the items creation (using .CreateShortcut).

Because you seemingly have to use the "Pin to Taskbar" verb to pin an item, it is not an option to do otherwise (unless someone else is aware of one). That being said, it will be necessary to figure out how to change the target of a pre-existing shortcut (.lnk) file. I'm in the process of figuring that out but have limited time to do so. I'll post any findings.

-Geates




"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Alright.
Now we´re talking about the same :- )

Thank you very much !
I´ll also try to find it out.


Cheers
Checkzen

 
Proud to present

Because Windows is a little buggy, artifact shortcuts may remain in the Taskbar folder even if they've been unpinned.

-Geates


"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hello there Geates :- )

Thanks for the fast solving !!

But I still do have a problem.
In line 87 sign 2 there´s an error.
It says: "Object needed: "objFolderItem".

Sorry for asking so much :- )


Cheers
Checkzen

 
What command are you using? The error suggests that the object you are trying to pin does not exists or is incorrectly referenced in the command line.

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top