troubleshooting Question

VBS script question

Avatar of martinlest
martinlest asked on
Visual Basic Classic
18 Comments1 Solution545 ViewsLast Modified:
Though I have some basic knowledge of vbs syntax, I am (as will be clear I think from the nature of my question) pretty much a beginner here. I have a VBS script which shows and hides hidden files. I was looking to find an addition to the script that would close the 'OK' message box after a given timeout. I have two other 'autotimeout' scripts but I can't see how to integrate them into my HiddenFile script - the best I can get is for the three scripts to run one after the other from one vbs file.

Can someone kindly indicate how to get my the message box 'OK' of my HiddenFile script to close after, say 3 seconds, using (or not!) one of these other two autoclosing scripts? (These latter have messages obviously irrelevant to the main script - I've just posted them 'raw').

Many thanks,



' Script to toggle Windows Explorer display of hidden files and super-hidden
' files

Option Explicit
Dim dblHiddenData, strHiddenKey, strSuperHiddenKey, strFileExtKey
Dim strKey, WshShell

On Error Resume Next

strKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
strHiddenKey = strKey & "\Hidden"
strSuperHiddenKey = strKey & "\ShowSuperHidden"
strFileExtKey = strKey & "\HideFileExt"

Set WshShell = WScript.CreateObject("WScript.Shell")
dblHiddenData = WshShell.RegRead(strHiddenKey)

If dblHiddenData = 2 Then
   WshShell.RegWrite strHiddenKey, 1, "REG_DWORD"
   WshShell.RegWrite strSuperHiddenKey, 1, "REG_DWORD"
   WshShell.RegWrite strFileExtKey, 0, "REG_DWORD"
   WScript.Echo "Windows Explorer will show hidden files" & _
      ". You might need to change to another folder or " & _
      "press F5 to refresh the view for the change to take effect."
   WshShell.RegWrite strHiddenKey, 2, "REG_DWORD"
   WshShell.RegWrite strSuperHiddenKey, 0, "REG_DWORD"
   WshShell.RegWrite strFileExtKey, 0, "REG_DWORD"
   WScript.Echo "Windows Explorer will not show hidden files" & _
      ". (These are the default settings.) You might " & _
      "need to change to another folder or press F5 to refresh the " & _
      "view for the change to take effect."
End If


dim naptime, objDOS
naptime = 2
set objDOS = CreateObject ("WScript.Shell")
objDOS.Popup "This box will close automatically "  , naptime, "Sleeper", 0


Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

intReturn = objShell.Popup("Do you want to delete this file?", _
    2, "Delete File", wshYesNoDialog + wshQuestionMark)

If intReturn = wshNo Then
End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 18 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros