Classic Shell/Explorer Custom Command

Page 1 of 2 12 LastLast

  1. BXF
    Posts : 8
    Windows 7 Pro 64bit
       #1

    Classic Shell/Explorer Custom Command


    Hi,

    I've created a Custom Command under Classic Explorer that invokes a VBS script. If the command contains E:\abcdef.vbs, it works. If, however, I change it to E:\abcdef.vbs "%3", nothing happens, even though there is no reference to the argument within the script.

    For what it's worth, here is the script:

    Dim WshShell, objFSO, FileList, strFileName, MKLCommand, I

    Set WshShell = WScript.CreateObject("WScript.Shell")

    Const ForReading = 1

    'FileList = WScript.Arguments(0)
    FileList="F:\Global Temp\ceiA611.tmp"
    WScript.Echo FileList

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile(FileList, ForReading)

    Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    I = InStrRev(strNextLine,"\")
    strFileName = Right(strNextLine,Len(strNextLine)-I)
    MKLCommand = "cmd.exe /c mklink ""E:\FPVTemp\" & strFileName & """ """ & strNextLine & """"
    WshShell.Run(MKLCommand)
    Loop

    Any suggestions would be appreciated.

    Thanks.
      My Computer


  2. Ivo
    Posts : 398
    Windows 7 Home 64, Vista Ultimate 64
       #2

    You can use Process Monitor to see if a process is being launched and with what exact parameters.
      My Computer


  3. BXF
    Posts : 8
    Windows 7 Pro 64bit
    Thread Starter
       #3

    I'm not sure exactly what I should be looking for, but I did find this, while monitoring Explorer.EXE:


    Operation: CreateFile

    Result: NAME INVALID

    Path: E:\MKLink.vbs "F:\GLOBAL~1\


    My TEMP folder is F:\Global Temp.

    Looks like the name being passed is truncated.

    This operation is preceded by some successful operations on F:\Global Temp\ceiF6DD.tmp.

    Thanks for your help.
    Last edited by BXF; 19 May 2013 at 18:49. Reason: More info
      My Computer


  4. Ivo
    Posts : 398
    Windows 7 Home 64, Vista Ultimate 64
       #4

    That's probably fine. It tries a few things to figure out what part is the exe and what part is the argument. To avoid confusion use quotes around E:\MKLink.vbs.
      My Computer


  5. BXF
    Posts : 8
    Windows 7 Pro 64bit
    Thread Starter
       #5

    Hi Ivo,

    I had already tried it with quotes before I posted. I tried again, but no change.

    I'm attaching two extracts from Process Monitor (renamed to .txt for upload). The difference is quite dramatic:)

    It may be useful to point out that replacing the .VBS with .BAT appears to work, even with the "%3".

    Thanks.
    Classic Shell/Explorer Custom Command Attached Files
      My Computer


  6. Ivo
    Posts : 398
    Windows 7 Home 64, Vista Ultimate 64
       #6

    Please attach the exact VBS file you are using, and the string you use for your command.
    Also, what are you trying to do?
      My Computer


  7. BXF
    Posts : 8
    Windows 7 Pro 64bit
    Thread Starter
       #7

    Script attached. It creates Symbolic Links for selected files, in another folder.

    The command (Copy/Pasted): "E:\MKLink.vbs" "%3"

    Enjoy!:)
    Classic Shell/Explorer Custom Command Attached Files
      My Computer


  8. BXF
    Posts : 8
    Windows 7 Pro 64bit
    Thread Starter
       #8

    Hi Ivo,

    I've solved MY problem by compiling the VBScript to an EXE, which runs fine.

    I do have another question, please. The Help section says "Note to developers: When %3 or %4 is used, it is the responsibility of the command to delete the temporary file when it finishes", but the file is locked until the command terminates (in use by Explorer). What is the proper way to get around this?

    Thanks.
      My Computer


  9. Ivo
    Posts : 398
    Windows 7 Home 64, Vista Ultimate 64
       #9

    I looked at the code and it seems fine. I close the file before calling the command, so the file shouldn't be in use.
    I will run some tests during the weekend.
      My Computer


  10. BXF
    Posts : 8
    Windows 7 Pro 64bit
    Thread Starter
       #10

    Sorry, stupid me. It is I who still has the file open (I'm not a Windows programmer).

    My apologies.
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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:32.
Find Us