Search code examples
windowsbatch-filecmdvbscript

How delete file to shell:startup from vbs?


I'm trying to delete a file from vbs, but I can't because this is a long extension and it must use quotation marks:

Set oShell = CreateObject ("Wscript.Shell")
    Dim strArgs6919
    strArgs6919 = "cmd /c del %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\SoftEther VPN Client Manager Startup"
    oShell.Run strArgs6919, 0, false

I can remove it manually without problem, but I want to do it from vbs, how I can solve this? Thanks very much and regards!


Solution

  • Here's a quick example based upon the cumulative advice you've received within the comments:

    ' VB Script Document
    Option Explicit
    Dim objFSO, objSh, strFile
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objSh = CreateObject("WScript.Shell")
    strFile = objSh.SpecialFolders("Startup") & "\SoftEther VPN Client Manager Startup.lnk"
    If objFSO.FileExists(strFile) Then objFSO.DeleteFile strFile, True