locked
VBscript NOT working properly for PC Awake RRS feed

  • Question

  • I am trying to have a script to keep unlock my PC always even I am away from it. The following vbscript not working when I use MsgBox. If I don't use MsgBox its working...any expert suggestions?

    -----------------------------------------------------------------------------------------------------------------------------------------

    Working Script:

    SET wsc = CreateObject("WScript.Shell") 
     
     Do 
             WScript.Sleep (30*1000)
             wsc.SendKeys ("{SCROLLLOCK 2}")
        Loop

    ==============================================NOT Working============================

    SET wsc = CreateObject("WScript.Shell")

    reponse = MsgBox ("Click OK Button AFTER your RETURN", vbOKonly, "PC Awake...Click OK to END")


     Do While reponse<>VbOK
             ' Wait for ~2 minutes
             WScript.Sleep (30*1000)
             wsc.SendKeys ("{SCROLLLOCK 2}")
        Loop

       
    • Moved by Neda Zhang Thursday, December 8, 2016 8:29 AM Moved from vb forum
    Wednesday, November 23, 2016 3:33 PM

All replies

  • This isn't a script forum. You can try Visual Basic for Applications (VBA) if that is VBA or The Official Scripting Guys Forum! I suppose.

    La vida loca

    Wednesday, November 23, 2016 3:36 PM
  • Best choice is the Script guy as per Mr. Monkey Boy.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, November 23, 2016 6:33 PM
  • Hi vvkprasad,

    Thank you for posting in MSDN Forum.

    >>The following vbscript not working when I use MsgBox. If I don't use MsgBox its working...any expert suggestions?

    Based on your description and code, I think the MsgBox and do-while loop should be placed in different application. If you execute MsgBox code and select OK, the do-while loop will not be executed.   

    Best Regards,

    Neda Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 24, 2016 9:31 AM