Pop up disclaimer

Posted on 2012-08-19
Last Modified: 2012-08-23
I have been asked to provide a link to view a folder, on the desktop of all users. I can do this without issue. I do have an issue with the security/privacy of the contents of the folder in question.
Out DC is SBS 2003 and I will be using a batch file called from the login script to create a short-cut on the desktop for each user at login.
I want to add a disclaimer pop-up that appears when the short-cut is launched. Again I can actually do this with a very simple VBScript file.
What I haven't been able to do, is add a cancel or exit button to the pop-up. The pop-up I have created just has an 'OK' button and then goes on to display the list. I want to give the user the chance to back-out instead of proceeding. So I need an 'OK' Button and a 'Cancel' button.
I will attach the VBScript file and this is how I call it:

cscript MessageBox.vbs "This will be shown in a popup."

Having said all that, I am not all that happy with the fact that the Command Prompt window sits behind the pop-up waiting for a repsonse from the user; is there a better and neater way to do this? May be some other way to call the VBScript file rather than from a batch file?

Question by:gregmiller4it
    LVL 1

    Expert Comment

    Hello Greg,

    I can't help much with the pop up box, but I have been able to hide the command prompt window in the past. They way i did it was with a VB script:

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "C:\Users\YourBatchFile.bat" & Chr(34), 0
    Set WshShell = Nothing

    How this helps with part of your problem. :)
    LVL 1

    Accepted Solution

    Hello again Greg,

    I made this up, hope it gets you off to a good start (please note I am not a scripting guru):

    Dim shell
    Set shell = wscript.CreateObject("Shell.Application")
    x=msgbox("This is important. Do you accept the responsibility?", 4,"IMPORTANT!")
    if x=6 then
         shell.Open "C:\YourFolder"
    elseif x=7 then
         msgbox"Security will be along soon to escort you out.", 0,"Oh My..."
    end if

    Here is a link for a basic guide to customise it to your needs:

    Good Luck!
    LVL 82

    Expert Comment

    To call this without a command shell in the background from a batch script, you'd need to start the VB script using wscript.exe, not cscript.exe:
    wscript.exe "This will be shown in a popup."

    Open in new window

    Now, for a simple popup box from a batch script, you could just use msg.exe (XP and later):
    msg.exe * "This will be shown in a popup."

    Open in new window

    (with a optional timeout as well).
    Here's a complete VB script that will warn, have an OK and Cancel button, close its box after a timeout (in case someone stares at the message like a deer caught in the headlights and doesn't dare to click anything), and open the folder in Explorer if (and only if) the "OK" button has been clicked. You can customize the message to your likings (a timeout of 0 means "wait indefinitely").
    Then create a shortcut to "%Systemroot%\system32\wscript.exe", add the location of the script as argument, and pick a symbol (for example from explorer.exe or %systemroot%\system32\shell32.dll), then copy this shortcut to the user desktop.
    Const mbOK = 0
    Const mbOKCancel = 1
    Const mbAbortIgnoreRetry = 2
    Const mbYesNoCancel = 3
    Const mbYesNo = 4
    Const mbRetryCancel = 5
    Const icCritical = 16
    Const icQuestion = 32
    Const icExclamation = 48
    Const icInformation = 64
    Const btOK = 1
    Const btCancel = 2
    Const btAbort = 3
    Const btRetry = 4
    Const btIgnore = 5
    Const btYes = 6
    Const btNo = 7
    Const btTimeout = -1
    strFolder = "C:\Temp"
    intMessageTimeout = 15
    strMessageTitle = "Access on a 'Need to Know' base only!"
    strMessage = _
    "Access to this folder is monitored." & vbCRLF & _
    "Are you sure you want to proceed?" & vbCRLF & _
    "(This message will self-destruct in " & intMessageTimeout & " seconds.)"
    Set objShell = CreateObject("WScript.Shell")
    intButton = objShell.Popup (strMessage, intMessageTimeout, strMessageTitle, mbOKCancel + icExclamation)
    If (intButton = btOK) Then
    	objShell.Run "explorer.exe " & Chr(34) & strFolder & Chr(34), 1, False
    End If

    Open in new window


    Author Closing Comment

    Thanks all for your suggestions. Jpoppi got me heading in the right direction and I used the link provided and did some more googling and have come up with a very satisfactory solution. In the end, it was really simple to avoid the black command window in the background when the message was on the screen; I was just using a command line to lauch the script because I had got to this point from previously using batch files. I had forgotten that a script can actually be launched directly (i.e. double-click the script file) and doesn't actually need to be launched from a command prompt...Doh!!! Sorry for leading eveyone down the wrong path there.
    Anyway, I am very happy with the end result. I have just pushed a short-cut to the script out to the desktop for all users. Here is the basics of my final script:

    Dim shell
    Set shell = wscript.CreateObject("Shell.Application")
    x=msgbox("The contents of this folder ...blah, blah, security warning" & Chr(13) & Chr(13) & "Do you wish to continue?",308,"IMPORTANT - Private and Confidential Client Information!")
    if x=6 then
         shell.Open "\\server\share\myfolder"
    elseif x=7 then

    end if

    So the above script throws up a pretty convincing security warning, with 'Yes' and 'No' as the options. 'Yes' opens the target folder, 'No' cancels the request.
    The double Chr(13) puts a blank line before the question "Do you want to continue?". The 308 = 4 (Yes/No) + 48 (Warning Message) + 256 (emphasis on second button i.e. 'No').

    Thanks again, it's been fun!
    LVL 1

    Expert Comment

    Glad you found a solution! :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    The articles for turning off the Client firewall policy on the internet are for SBS 2008 and don't really help for SBS 2011. They actually moved the Client firewall policy. In 2011, the client firewall policy has moved to the SBS computers conta…
    If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now