I'm using the MenuEdit API to dynamically create a menu of a list of shares available on a machine.
So you have a menu entitled BROWSE and then a submenu from that with the various share names (e.g. C$, ADMIN$, IPC$ etc). When a menu item is clicked I would like to call a VBScript subroutine that receives the name of the menu item that was clicked so that I can open Windows Explorer for that partiular share.
How can I do this?
Alternatively, is there a way to dynamically create the menu item so that the onclick command is "Open windows Explorer at this share"?
Calling a VBScript sub using the menu text as a parameter?
I get various information about the shares but I guess the two most important variables I need to pass are the machine name (e.g. HBRUXXXX1) and the path of the share (e.g. \\SERVER\FOLDER1\FOLDER2)
I used to call a simple VBscript subroutine that would open Windows Explorer passing the path as a parameter. Now that I am using the menu system I would like it to either
a) Call the same VBscript subroutine passing the path as parameter
b) Open the path directly (window.open??)
OK here's the code that creates the menu items
function BrowseMenus(machine,share,path)
{
mm_insertItem('BrowseMenuSubs',1,'text=' + share + ';url='+ path +';')
}
share is the name of the share (e.g. C$) and path is, obviously, the name of the share's path
This is the VBscript function that (previously) was called to open a selected share. The user would select the share from a listbox (hence the ShareList.Value) parameter. Ideally, I would like this Function called when the user clicks the submenu item
Function OpenShare()
If IPBox.Checked Then
objShell.Run("explorer.exe \\" & varIP & "\" & ShareList.Value)
Else
objShell.Run("explorer.exe \\" & PCList.Value & "\" & ShareList.Value)
End If
End Function
I used to call a simple VBscript subroutine that would open Windows Explorer passing the path as a parameter. Now that I am using the menu system I would like it to either
a) Call the same VBscript subroutine passing the path as parameter
b) Open the path directly (window.open??)
OK here's the code that creates the menu items
function BrowseMenus(machine,share,path)
{
mm_insertItem('BrowseMenuSubs',1,'text=' + share + ';url='+ path +';')
}
share is the name of the share (e.g. C$) and path is, obviously, the name of the share's path
This is the VBscript function that (previously) was called to open a selected share. The user would select the share from a listbox (hence the ShareList.Value) parameter. Ideally, I would like this Function called when the user clicks the submenu item
Function OpenShare()
If IPBox.Checked Then
objShell.Run("explorer.exe \\" & varIP & "\" & ShareList.Value)
Else
objShell.Run("explorer.exe \\" & PCList.Value & "\" & ShareList.Value)
End If
End Function
Any ideas on this? It's the last main hurdle to overcome before I can release the latest version of my HTA 
I've got a semi-OK workaround that builds a parameter from the machine name and the sharename (e.g. \\HBRUXXXX\C$) and then passes that as the URL value. That's OK but it means the share is opened in Internet Explorer rather than Windows Explorer.

I've got a semi-OK workaround that builds a parameter from the machine name and the sharename (e.g. \\HBRUXXXX\C$) and then passes that as the URL value. That's OK but it means the share is opened in Internet Explorer rather than Windows Explorer.
It looks like I should be able to use the PassItemRef module to get this information but I'm having trouble with it. Here's how I build the menu items for the shares
mm_insertItem('BrowseMenuSubs',1,'clickfunction=TestSub2();text=' + share +';')
So, each menu item just contains the name of the share and, when clicked, called TestSub2. What I need TestSub2 to do is find out what menu item called it. Can I use the PassItemRef module for this somehow?
mm_insertItem('BrowseMenuSubs',1,'clickfunction=TestSub2();text=' + share +';')
So, each menu item just contains the name of the share and, when clicked, called TestSub2. What I need TestSub2 to do is find out what menu item called it. Can I use the PassItemRef module for this somehow?
Never mind - after much trial and error I've found a way to do it. The menu items are built, as I said, with menuedit.js and it was simply a matter of formatting!
function BrowseMenus(share)
{
shareforfunction=String.fromCharCode(34) + share + String.fromCharCode(34)
mm_insertItem('BrowseMenuSubs',1,'clickfunction=OpenShare(' + shareforfunction + ');text=' + share +';')
}
The function that builds the menu items receives the variable share but now has to add quotes around it so that it can be passed BACK to a Vbscript function as a variable when the menu item is clicked. I guess it's a bit of a hack but it works well enough.
function BrowseMenus(share)
{
shareforfunction=String.fromCharCode(34) + share + String.fromCharCode(34)
mm_insertItem('BrowseMenuSubs',1,'clickfunction=OpenShare(' + shareforfunction + ');text=' + share +';')
}
The function that builds the menu items receives the variable share but now has to add quotes around it so that it can be passed BACK to a Vbscript function as a variable when the menu item is clicked. I guess it's a bit of a hack but it works well enough.