Windows 10中的“ Pin启动”

时间:2019-02-20 15:31:14

标签: windows shell delphi execute

我正在尝试编写一个将应用程序自动固定到开始菜单的delphi应用程序,以便在平板电脑模式下可以轻松看到它们。

我做了一些研究,发现所有内容都是可以工作的VBScript(请参见下面的代码)。

所以我试图用Shell Execute在我的delphi应用程序中打开VBScript

ShellExecute(Handle, 'open', Pchar('C:\tmp\VBScript.vbs'), 'C:\WINDOWS\system32\ notepad.exe', nil, SW_NORMAL);

但是,如果我尝试使用shell execute运行脚本,则没有“ Pin to start”动词。否则,如果我直接从资源管理器中打开它,它将起作用。

直接从Windows资源管理器或带有shell execute的delphi运行文件有什么区别?

还是您有一个主意,我该如何尝试仅使用delphi固定应用程序?

VBScript:

Dim Argumente
Dim File, objFSO
Dim strFolder, strExecutable

Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
arg0 = wscript.arguments.unnamed.item("0")
arg1 = wscript.arguments.unnamed.item("1")

File = arg0&arg1

If (objFSO.FileExists(File )) Then 
Else
WScript.Echo "File " & File & " gibt es nicht. Script fehlgeschlagen"
WScript.Quit(2)
End If

strFolder = arg0
strExecutable = arg1

WScript.Echo "Folder:" & strFolder & ""
WScript.Echo "File:" & strExecutable & ""

Set objFolder = objShell.Namespace(strFolder)
Set objFolderItem = objFolder.ParseName(strExecutable)

Set colVerbs = objFolderItem.Verbs

'uncomment this section to display the available verbs
 For Each objVerb In colVerbs
    If objVerb <> "" Then
       WScript.Echo objVerb
    End If
 Next

'Loop through the verbs and if PIN is found then 'DoIt' (execute)
blnOptionFound = False
For Each objVerb In colVerbs
   If Replace(objVerb.name, "&", "") = "Pin to Start" Then
      objVerb.DoIt
      blnOptionFound = True
      WScript.Echo "The application '" & strExecutable & "' was just Pinned to the Start Menu."
      WScript.Quit(0)   
End If
Next

if blnOptionFound = false then
   WScript.Echo "The application '" & strExecutable & "' was already pinned to the Start Menu."
   WScript.Quit(1)   
end if

1 个答案:

答案 0 :(得分:1)

有一个用于固定开始菜单项的特殊文件夹,您可以在其中放置程序的快捷方式

https://superuser.com/a/171129/442240

因此无需为此使用复杂的技巧