Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Creating Network Browse Dialog

Created: 29 Oct 2012 • Updated: 06 Nov 2012 | 15 comments
This issue has been solved. See solution.

Using Wise Package Studio 8...

Is it possible to have the Browse button within a dialog, only browse a list of servers on the network and any shared folders each may have?

Then put the UNC path of my selection into a Property?

So I could select a server called "SERVER A" and then select one of it's shared folders called "SHARE", click the OK button and have something like:

\\Server A\Share stored in a property.

Discussion Filed Under:

Comments 15 CommentsJump to latest comment

Paul1977's picture

Appologies for chasing but did anyone have an idea on how this would be accomplished?
 

Andy Welburn's picture

Have move to what I hope is the correct forum - hopefully you will get a resolution here.

Paul1977's picture

Ok thank you.

Actually I think I'm almost there now but just have a couple of issues remaining.

I put this vbscript together which runs fine when you save as a .vbs file and run within windows:

Const MY_COMPUTER = &H12&
Const WINDOW_HANDLE = 0
Const OPTIONS = &H10&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
    (WINDOW_HANDLE, "Select the SNAPSHOT Folder:", OPTIONS, strPath)
     
If objFolder Is Nothing Then
    Wscript.Quit
End If

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

Wscript.Echo objPath

I quickly found out that the above script needed ammending when run as a CA (Call VB Script From Embedded Code) as commands such as Wscript don't work so I've ended up with the below, which also passes the INSTALLDIR parameter so I can feed that back into my 'Show Install Directory' box.
 

Const NETWORK = &H12&
Const WINDOW_HANDLE = 0
Const OPTIONS = &H10&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
    (WINDOW_HANDLE, "Select the SNAPSHOT Folder:", OPTIONS, strPath)

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

Session.TargetPath("INSTALLDIR")=objPath

It kinda works but I have a couple of things I just can't resolve.
First thing is the problem where it appears behind the MSI window which is a real pain, there has to be someway round this? If I used Call VB Script From Installation would that mean I could no longer pass the INSTALLDIR through it? I thought perhaps that may get around this problem.

Second issue is when you click the Cancel button, it throws an error saying:
"Installation ended prematurely because of an error"
Internal Error Internal Error 2896

EdT's picture

In your code, why do you state: Set objShell = CreateObject("Shell.Application") twice?  Declaring it once at the start of your code should be sufficient, as you are still using the same object.

Your problem where the script appears behind the MSI window - what exactly do you want to achieve? A hidden window or your script "on top" ?

Call VBScript from Installation should work just as well, as a Type 6 custom action is stored in the binary table and loaded when required. You may need to think about exactly where you plan to sequence your action in the UI sequence, and also cater for the situation where someone tries to run the install silently and the UI sequence is therefore not run at all. Presumably you would provide a way of setting INSTALLDIR via the property table.

Also, you can choose "Ignore Exit Code" as an option on your custom actions. This would do exactly what it says, ignore any non-zero exit code and just continue on. On cancel therefore, your app would presumably default back to the preset value of INSTALLDIR, or would you want to abort the install?

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Paul1977's picture

Hi, thanks for helping.

Calling that piece of code twice was a mistake, taken the 2nd reference out now, thanks.

Where the window is appearing behind the MSI window, that should not be hidden as it looks like this when it pops up... it needs to be on top really.

Thanks for pointing out the 'Ignore Exit Code' option, that fixed the Cancel button issue. When the Cancel button is clicked then this popup just closes and returns you back to the MSI, defaulting back to the present value of INSTALLDIR, doesn't need to abort the installation.

I have changed to a Type 6 custom action which works ok. Actually I noticed by setting the processing option to 'Syncronous Ignore Exit Code' it changes the type to back 70 anyway.

So I just need to figure out how to bring the window to the front everytime now.

EdT's picture

With custom actions, the Type number is combined with other attributes which you can research in the help file MSI.CHM. So the type "70" is actually a type 6 custom action plus the attribute 64, which means: "Synchronous execution that ignores exit code and continues."

The answer to your dialog question can also be found in the help file MSI.CHM, under Dialog Table. By location this specific dialog in your project's dialog table you can control its location on the page with the HCentering and VCentering parameters, and set the Attributes. The Attributes section has a link that takes you to "Dialog Style Bits" where you should try setting the Modal attribute which should ensure that your dialog has the focus when it opens.

I have a link to MSI.CHM in my quicklaunch bar as it is such a useful reference to the inner workings of MSI tables.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Paul1977's picture

Yes the MSI.CHM help file is extremly useful and tend to use it lots.

But you can't set any dialog options like you say, when the dialog box itself is being created by a vbscript though can you? I can't see a reference to it in the Dialog table.

EdT's picture

Sorry, must have missed the reference to vbscript.  I know that in VBScript functions such as msgbox, there is an options to set a system modal attribute, which forces the message box to the top of any stack of windows, and remain there until the OK or Cancel button is pressed. Without seeing your code I can't do more than suggest that you look for ways to set the window properties for the dialog as system modal.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Paul1977's picture

Ok that's fine. I've been looking around trying to find some examples. I know about setting the msgbox function where you can set systemModel 4096. Only problem with that is I'd have an extra box appear.

I learned about using Wsh.AppActivate function today but not sure if that can be utilised in my script.
Shame really, I would have thought there must be some trick to do, best go and brush up my vbscript skills some more I guess.

If you can think of anything then by all means let us know! Thanks for your help btw.
Script is this:
 

Const NETWORK = &H12&
Const WINDOW_HANDLE = 0
Const OPTIONS = &H10&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path

Set objFolder = objShell.BrowseForFolder _
    (WINDOW_HANDLE, "Select the SNAPSHOT Folder:", OPTIONS, strPath)

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

Session.TargetPath("INSTALLDIR")=objPath

EdT's picture

I'm not a programmer, so like you I tend to research code on the net when I have a specific requirement. One option, although not hugely elegant, is to use something like AutoIT to identify a specific window and bring it to the front. You would then launch the AutoIT program ahead of your dialog, so it sits in the background waiting for the dialog window to appear, then it brings it to the front and terminates. You would need to run this CA as an asynchronous CA so that execution continues without waiting for an exit code.

On the other hand, if anyone reading this has a better solution, please share with us!

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

VBScab's picture

Is this not possible using standard WI dialogs?

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Paul1977's picture

Standard Wise Dialogs you mean VBScab??

That was my first thought before going down this route.. do you know how to create a network pop up box from wise scripts that show just the servers on the network and any shares they may have?

That would be most useful to have. If that's possible then fantastic, not entirely sure on how to accomplish it though, will have a go at it though.... any suggestions or examples will be greatly appreciated at this time.

VBScab's picture

If you're actually using WiseScript then, as I understand it - I've never played with WiseScript - you can set up access to Windows APIs, in which case you can call up the dialog natively, using pretty much the same values you have in your VBScript code.

Search Connect for WiseScript calling Windows APIs.

EDIT:

http://wisescript.dragonsoft.us/scripts_4.php

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

SOLUTION
Paul1977's picture

That has to be the most useful site I've come across yet, thank you.

The example given on there called 'Shell API Interface' will do exactly what I need but through Wise Scripts which will be better. It will require some modifications for sure which I can sort out so thanks again for both your help, learnt a lot out of all this!

Paul.

VBScab's picture

I wouldn't invest too much time in WiseScript, though. It's a dead end. Flexera (or whoever owns InstallShield this week...) have made the right noises about supporting it but I wouldn't hold my breath.

If you absolutely *must* have access to Windows APIs, I would investigate one of the DLLs which offer an interface to them via script. I've used DynaWrap in the past with some success but ending up writing my own.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.