我有一个VB脚本,它有一个相应的.bat文件,把它放在“C:\users\default\appdata\roaming\microsoft\windows\start menu\programs\startup”文件夹中。但是,在启动时,脚本不会完全运行。脚本应该创建任务栏快捷方式,但没有为我列出的Office产品创建快捷方式。
下面是脚本:
Option Explicit
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_PROGRAMS = &H2
Const CSIDL_STARTMENU = &HB
Const CSIDL_CURRENT_USER_DESKTOP = &H10
Const CSIDL_PUBLIC_DESKTOP = &H19
Dim objShell, objFSO
Dim objCurrentUserStartFolder
Dim strCurrentUserStartFolderPath
Dim objCurrentUserDesktopFolder
Dim strCurrentUserDesktopFolderPath
Dim objAllUsersProgramsFolder
Dim strAllUsersProgramsPath
Dim objPublicDesktopFolder
Dim strPublicDesktopFolderPath
Dim objFolder
Dim objFolderItem
Dim colVerbs
Dim objVerb
Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCurrentUserStartFolder = objShell.NameSpace (CSIDL_STARTMENU)
strCurrentUserStartFolderPath = objCurrentUserStartFolder.Self.Path
Set objCurrentUserDesktopFolder = objShell.NameSpace (CSIDL_CURRENT_USER_DESKTOP)
strCurrentUserDesktopFolderPath = objCurrentUserDesktopFolder.Self.Path
Set objAllUsersProgramsFolder = objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path
Set objPublicDesktopFolder = objShell.NameSpace (CSIDL_PUBLIC_DESKTOP)
strCurrentUserDesktopFolderPath = objPublicDesktopFolder.Self.Path
' - Remove pinned items -
'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs")
Set objFolderItem = objFolder.ParseName("Internet Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If
'Google Chrome
If objFSO.FileExists(strAllUsersProgramsPath & "\Google Chrome\Google Chrome.lnk") Then
Set objFolder = objShell.Namespace(strAllUsersProgramsPath & "\Google Chrome")
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
'Windows Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Unpin from Taskbar" Then objVerb.DoIt
Next
End If
'Windows Media Player
If objFSO.FileExists(strAllUsersProgramsPath & "\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
' - Pin to Taskbar -
'Mozilla Firefox
If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk") Then
Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\")
Set objFolderItem = objFolder.ParseName("Mozilla Firefox.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
'Windows Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Accessories\Windows Explorer.lnk") Then
Set objFolder = objShell.Namespace(strCurrentUserStartFolderPath & "\Programs\Accessories")
Set objFolderItem = objFolder.ParseName("Windows Explorer.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
'Microsoft Office Word
If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\Word 2013.lnk") Then
Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
Set objFolderItem = objFolder.ParseName("Word 2013.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
'Microsoft Office Excel
If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\Excel 2013.lnk") Then
Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
Set objFolderItem = objFolder.ParseName("Excel 2013.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
'Microsoft Office Powerpoint
If objFSO.FileExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\PowerPoint 2013.lnk") Then
Set objFolder = objShell.Namespace("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office\Microsoft Office 2013\")
Set objFolderItem = objFolder.ParseName("PowerPoint 2013.lnk")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
End If
' - Remove IE shortcuts from start menu -
'Internet Explorer
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk") Then
objFSO.DeleteFile(strCurrentUserStartFolderPath & "\Programs\Internet Explorer.lnk")
End If
'Internet Explorer 64-bit
If objFSO.FileExists(strCurrentUserStartFolderPath & "\Programs\Internet Explorer (64-bit).lnk") Then
objFSO.DeleteFile(strCurrentUserStartFolderPath & "\Programs\Internet Explorer (64-bit).lnk")
End If
' - Remove Thunderbird from current user desktop -
If objFSO.FileExists(strCurrentUserDesktopFolderPath & "\Mozilla Thunderbird.lnk") Then
objFSO.DeleteFile(strCurrentUserDesktopFolderPath & "\Mozilla Thunderbird.lnk")
End If
' - Remove Thunderbird from public desktop -
If objFSO.FileExists(strPublicDesktopFolderPath& "\Mozilla Thunderbird.lnk") Then
objFSO.DeleteFile(strPublicDesktopFolderPath& "\Mozilla Thunderbird.lnk")
End If
' - Remove Google Chrome from current user desktop -
If objFSO.FileExists(strCurrentUserDesktopFolderPath & "\Google Chrome.lnk") Then
objFSO.DeleteFile(strCurrentUserDesktopFolderPath & "\Google Chrome.lnk")
End If
' - Remove Google Chrome from Public desktop -
If objFSO.FileExists(strPublicDesktopFolderPath & "\Google Chrome.lnk") Then
objFSO.DeleteFile(strPublicDesktopFolderPath & "\Google Chrome.lnk")
End If
'Delete the script
DeleteSelf
Sub DeleteSelf()
Dim objFSO
'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Delete the currently executing script
objFSO.DeleteFile WScript.ScriptFullName
Set objFSO = Nothing
End Sub
下面是.bat文件:
mkdir "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
copy /y SetShortcuts.vbs "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
你知道为什么这行不通吗?
答:我想通了。我把文件路径名弄错了,因为如果计算机上安装了以前版本的Office的话,路径会不同。
默认用户配置文件是所有已创建用户的模板配置文件。无论何时创建新的用户配置文件,配置文件都是基于默认的用户配置文件构建的。
将文件复制到“%AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\Startup”
。
我有一个在pi模型3B上运行的selenium脚本,当使用 /usr/bin/python /home/pi/main.py手动运行时,该脚本运行得很好,但是当使用crontab或LXDE-pi/autostart运行它时,它只是启动浏览器,不会继续做它应该做的事情。我试图使用日志库记录信息,但没有看到任何有用的东西。起初我认为这是因为selenium没有随sudo安装,但它在python随sud
我想在我的Parallela板启动时运行一个bash脚本,它有Ubuntu。我搜索了SO,在这里找到了说明: 在linux ubuntu下启动时自动运行程序 在Linux上启动时以编程方式运行 我的bash脚本是test。sh,只有一行: 1) 我尝试的第一种方法是添加到脚本的aboslute路径: 2) 我尝试的第二种方法是遵循上面公认的答案。 在这两种情况下,脚本都是在引导后执行的,并且有一个
我试图在启动时运行我python脚本,但它不起作用。 下面是我的python脚本(不起作用): 这是我的python脚本(works): 下面是我的rc.local文件(也可以尝试crontab并在/ect/init.d中设置服务): 看起来通过导入paho.mqtt.发布可以让我的脚本停止工作,我是Linux的新手,我不知道为什么。有人可以帮助我吗?感谢您的帮助。 Ubuntu 16.04 如果
问题内容: 首先,这可能需要移至超级用户。我无法确定哪个场地更好。 我正在尝试编写一个将在启动/重新启动时运行的R脚本,并将该计算机添加到doRedis工作者池中。(doRedis是一个foreach后端)。 这是我的R脚本“〜/ Rworker.R” 我可以使用command从命令行运行此脚本 。 接下来,我编写了一个shell脚本来运行R脚本,标题为“ /etc/init.d/StartWor
问题内容: 我有一个node.js脚本,需要在启动时启动 并 在www-data用户下运行。在开发期间,我始终使用以下命令启动脚本: 我确切地看到了发生了什么,manager.js现在运行良好。搜索所以我发现我不得不把它放在我的。另外,我学会了将输出指向日志文件,并将追加到“将stderr重定向到stdout”,它应该是守护程序,因此最后一个字符是。 最后,我的样子是这样的: 如果我自己运行此代码
本文向大家介绍在Windows启动时自动运行Python脚本?,包括了在Windows启动时自动运行Python脚本?的使用技巧和注意事项,需要的朋友参考一下 将Python脚本添加到Windows启动时,基本上表示Python脚本将在Windows启动时运行。这可以通过两步过程来完成- 步骤#1:在Windows启动文件夹中添加或添加脚本 在启动Windows后,它会执行(相当于双击)其启动文件