0

On a Windows desktop I want to right click on a file, choose a custom menu item in the popup list, which when clicked on makes an HTTP request to call an ASP page on a Windows servers. This is all inside a corporate network.

I'm thinking I will right a VB Script to perform the http request so that I can grab the fully qualified file name and pass it as a parameter.

A long time ago I did CGI based web programming using html forms with a submit button to specify the href and the form fields were sent across with the http request as name value pairs.

How can I do a similar thing in the VB Script except call an ASP page (or method) to pass the file name to the ASP page?

In the ASP page what method would the request go to? In that method I will use the file name to do some processing.

Scott V
  • 25
  • 6
  • 1
    See http://stackoverflow.com/questions/2123762/add-menu-item-to-windows-context-menu-only-for-specific-filetype. You just need to add a custom action with the URL and variable for the filename. For the ASP page, just search on how to access URL parameters--pretty basic stuff. – Tony Hinkle Jun 25 '15 at 14:59

1 Answers1

0

A registry entry similar to the following will allow you to right-click on any file and click on a "Do Something" item, which will use PowerShell to submit the URL with the filename at the end as the "file" parameter.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Do Something\command]
@="powershell invoke-webrequest 'http://www.mywebsite.com/?file=%1'"

If you only want this item to be available on certain types of files, then you'll need to do a little research or tinkering to find exactly where to put it. For example, for this to work only .txt files, you would replace the "*" with "txtfile".

If you want only the filename and not the entire path, you can use .NET methods to get just the filename when you process it in the codebehind.

In ASP, use the Request.QueryString to access the filename that was passed in the URL:

Dim ClientFile as String = Request.QueryString("file")
Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
  • Thanks. That is very useful information. I'd like to make the http request without bringing up IE so I think I'll have to use a VB Script or PowerShell Script to do that.? Do you agree? – Scott V Jun 25 '15 at 16:33
  • Sure--PowerShell invoke-webrequest would be the easiest thing to do: https://technet.microsoft.com/en-us/library/hh849901.aspx – Tony Hinkle Jun 25 '15 at 16:36
  • @ScottV I have updated the answer to make it a PowerShell request instead of launching IE. Please mark it as the accepted answer if appropriate. Thanks! – Tony Hinkle Jun 25 '15 at 16:43