How to get file name of currently selected file using vbs RRS feed

  • Question

  • I need to be able to right click a file and have the filename passed as a variable or a string to clipboard so it is available for use in an associated vbs script that runs from the right click menu.

    This is what I need.

    Right click a file in an open window or on the desktop, king.txt for example. Select the right click menu item called 'Make folder and name it from filename\clipboard'. The utility then creates a folder with the selected file's name, with out it's extension. In this case it would create a folder called 'Ken'

    This is the batch file version I have been using for a couple of years.

    @echo off
    attrib -r -s -h %1
    set dest="%1"
    md "%~n1"
    move /-y "%Dest%" "%~n1"
    set dest=

    I have a registry file to set up the right click menu option.

    I cannot find any way to do this using vbs, I not experienced using vbs so I'm going crazy trying to do what I'm sure is a very basic task.

    Can you 'Please' help me out.


    • Moved by Bill_Stewart Friday, March 15, 2019 3:00 PM Not a scripting question
    Friday, December 7, 2018 10:30 PM

All replies

  • You need to post thisi the Windows forum for your version of Windows.  You can also search for articles telling you how to customize the menu.  It is not done via a batch file.  YOu need to create a key that calls a VBScript with the current item that is being right clicked.

    Search for "add to explorer right click menu".  You will find many articles explain how to do this.

    Here is the first one found: https://www.itprotoday.com/devops-and-software-development/how-do-i-add-item-right-click-menu


    • Edited by jrv Friday, December 7, 2018 10:46 PM
    Friday, December 7, 2018 10:44 PM
  • Just change the registry entries to point to your script instead of the bat file. 

    IE; change   "cmd.exe /c c:\Utilities\BuildFolder.bat %1"

    to "cscript.exe c:\Utilities\BuildFolder.vbs %1"

    If that doesn't make sense to you, please share your registry file, and explain what you are trying to do with VBS. 
    • Edited by MotoX80 Saturday, December 8, 2018 3:39 AM
    Saturday, December 8, 2018 3:29 AM
  • https://ss64.com/vb/syntax-args.html
    Saturday, December 8, 2018 2:11 PM