VBScript: Sometimes the msgbox message text is just ... Blank. (??) (1 Viewer)

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
I've given my users (and myself) a desktop shortcut. The shortcut points to a .vbs vbscript file on the network (full UNC path referenced). I know the network connection is fine, because 1) the shortcut's custom icon is visible, which resides on the network, and 2) the whole VBScript file works just fine - with the exception of this one very strange and perplexing oddity.

About 20% of the time, the msgbox (which is right at the top of the vbscript - first line of executable code) - simply fails to display the message. It just has the 'OK' button. Users don't mind terribly, they trust me and simply click OK, since that's the only button/option I've given them.

Any idea why ????

Here is the VBScript - up to the point of the msgbox.

Code:
'present a message box so that the user knows "something" is happening with this vbscript
'make sure the user has a folder in their appdata, to hold the database
'copy the latest network file into that folder
'open that file

dim strAppDataFolder, strFullPathToDatabaseFolder, fso, AccessApp

msgbox "Press OK to open the [name redacted] Database",vbInformation,"  "

(Google wasn't much help to me. No matter how I thought to try wording the search terms, the results were totally irrelevant)
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:00
Joined
Jul 9, 2003
Messages
13,576
I noticed that your question has yet to receive a reply. I have bumped it up the list so that it gets a second shot!
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
I have the exact same issue...and I am as dumbfounded as you as to why. It is completely outside of any loops, If statements , etc.

On of the reasons I am contemplating PowerShell.
 

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
Isn't it the weirdest thing ever? I've always known I ought to add powershell to my repertoire. I've been too lazy to put the time in so far

Go for it
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
I was hoping for "Hey John, allow ME to write it for you so I can learn!!"
 

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
Ha sorry. I've rubbed shoulders with a number of guys who used PS instead of VBS, but I've never come across a really specific and big reason why it's better (although there may be) so never had the motivation. If PS was easier to debug or step through that would be one. Then again, I think there are programs you can use to debug a vbscript, just never used one
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
Reasons NOT to switch...

vs

Why you should!

For my situation, there is no real compelling reason to make switch. Having said that, I want to see if I can pull it off. I KNOW I can, but I want to see how pissed off I am going to get doing it... :cool:
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
Last edited:

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
Those timeout popups are 'purt cool. I wonder if there is a way to do that in Access...
And there is:


Code:
Public Sub PopUp
    Dim objShell as Object
    Set objShell = VBA.CreateObject("WScript.Shell")
  
    objShell.PopUp "AWF rocks!", 1 ' TIMEOUT parameter in seconds'
  
    Set objShell = Nothing
End Sub
 
Last edited:

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
Just saw this - yes indeed, that's very cool @Gasman , thanks for sharing. I never knew that. It's interesting that most of the parameters and constant values seem to mirror the Msgbox (which is what I used rather than wscript.echo).

Next time I need to do this I'll switch to this new method, try it out. TY !
 

JMongi

Active member
Local time
Today, 09:00
Joined
Jan 6, 2021
Messages
625
I have limited experience of course, but I've already run into flakiness with MsgBoxes when I use the verbose form of the parameter settings (such as vbOK, vbInformation) instead of enumeration. I realize that the typical delineation involves early/late binding, but my unscientific feeling is that sometimes it doesn't resolve correctly giving strange weird errors.

Specifically related to PS and MsgBoxes, in my Googling it appears the "easiest" way to replicate that functionality is actually to load the VisualBasic libraries and use those! So, you'd be switching to PS and then dealing with VB anyway! You CAN use Windows Forms and System Displays with PS. So, that is powerful. However, as with most powerful tools, the overhead for doing so is deemed overkill for a simple message box. The flip side would be that once you had your overkill powershell messagebox function defined, you could drop it at the top of your script and call as needed. If you were REALLY feeling your Wheaties, you could use .NET or C# to program your own MsgBox cmdlet and then all of the Powershell kingdom would rejoice....yay! :ROFLMAO:
 

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
That's interesting. Add this to the list of things I might try (using the numeric value) if I ever wake up feeling like solving this problem - right now they aren't even using it, my evidence suggests they haven't used it since August. I guess they are busy in this season, unfortunately, we wanted the database used ("Reconciliation") in order to benefit us NOW - and NOW is here, but Reconciliation wasn't done :(

Powershell sounds fun.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:00
Joined
Feb 28, 2001
Messages
21,222
Regarding the initial question: When you supply ".... [Name Redacted] ... " in your code snippet, what was the FORM of the material that was redacted? A simple proper name or a substituted name via concatenation?
 

Isaac

Lifelong Learner
Local time
Today, 06:00
Joined
Mar 14, 2017
Messages
5,933
I'll just go ahead and provide the actual code in the file. Not sure why I originally felt this had to be redacted, it's really nothing.

Code:
msgbox "Press OK to open the Reconciliation Database",vbInformation,"  "
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 09:00
Joined
Apr 27, 2015
Messages
4,369
In the spirt of the rabbit-hole this thread has gone down (PS/VBScript), Daniel Pineault has done a few articles recently on VBA and PowerShell and how they can work together.

Here is the latest one.
 

Users who are viewing this thread

Top Bottom