Pop up disclaimer

Posted on 2012-08-19
Medium Priority
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
  • 3

Expert Comment

ID: 38310634
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. :)

Accepted Solution

Justin earned 1500 total points
ID: 38310649
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 85

Expert Comment

ID: 38310891
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

ID: 38319220
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!

Expert Comment

ID: 38324740
Glad you found a solution! :)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

830 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