Windows 10: Using .vbs to sleep pc

Discus and support Using .vbs to sleep pc in Windows 10 Gaming to solve the problem; So i'm using this command to put pc to sleep a vbs script. When I execute the command it signs me out but not sleep pc. Could you modify it so pc... Discussion in 'Windows 10 Gaming' started by AD, Sep 10, 2022.

  1. AD
    AD Win User

    Using .vbs to sleep pc


    So i'm using this command to put pc to sleep a vbs script. When I execute the command it signs me out but not sleep pc. Could you modify it so pc sleeps.Dim objShellSet objShell = CreateObject"Shell.Application"objShell.ShutdownWindowsset objShell = nothingSet WshShell = CreateObject"WScript.Shell"With objShellWScript.Sleep 200WshShell.AppActivate "Shut Down Windows"WshShell.SendKeys "ss"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{Enter}"End WithSet objShell=Nothing

    :)
     

  2. VBS Msgbox

    Denis,

    • I was too lazy to compute the size programmatically. And, it the 2005 version the message box always came up hidden, so I always used 0 for the top. It's also part of my OCD to be able to control everything.
    • I personally don't need it to timeout. I used this in vbs files to ask to continue to the next step, skip the next step or cancel the vbs. BTW, I added the code back in but keep it assign it to 0.
    • Sound was calling Windows Media Player: WshShell.Run "C:\Users\donast\desktop\sndrec32.lnk",7,false the lnk is a shortcut on my old desktop that had: "C:\Program Files (x86)\Windows Media Player\wmplayer.exe"
      "C:\Users\Public\Music\Wavefiles\Twilight.wav"
    • Yes. The value is the number of the button in the order specified when calling it.
    • Never really thought about it as all my VBS/VBA code is relatively simple and I add comments in the file as necessary to remind me what is going on. I don't usually have anyone to share my code.
    FYI I use a VBS to call it. Here's a line from a test vbs I use to run your version:

    choice=Wshshell.run("custommsgbox.vbs " & wscript.scriptname & " ""CopyFiles.vbs done. Continue with UnArchVista.vbs?"" ""White"" ""Black"" 40 ""Yes"" ""No"" ""Cancel""",1,true)

    Copy it to a text editor to see all the spaces, etc. Took me a while back the to figure it out.

    Don
     
    DRARetired, Sep 10, 2022
    #2
  3. Sleep

    Hi,

    This may happen due to its power plan. A power plan is a collection of hardware and system settings that manages how computers use and conserve power. For this, we suggest that you reset and restore power plans to its default. kindly follow these steps:

    • Open the Command Prompt (Admin).
    • Copy and paste the command below into the command prompt, and press
      Enter
      :
      • powercfg -restoredefaultschemes
    • Close the Command Prompt window, and then restart your PC to apply the changes.

    After that, go to Power & sleep settings
    by typing it into the Windows Search. Check the When plugged in, PC goes to sleep after
    settings is set to Never.

    Let us know if the steps above helped you to resolve the issue.
     
    Janeane Cru, Sep 10, 2022
    #3
  4. jaydub Win User

    Using .vbs to sleep pc

    Trouble Putting PC to Sleep

    I finally determined what the cause of my PC waking up right after I invoke sleep function Start > Power > Sleep. I recently purchased a Velocifire wireless (2.4ghz) keyboard that also comes with a USB cord so it can be used in corded mode. When used in corded mode, sleeping the PC is not a problem. When I use the wireless dongle, the PC refuses to sleep for more than a second. So, the wireless mode of this keyboard is what triggers the problem. In addition to the things I've tried in my original post, here are the results of some suggestions you guys made:
    • Created a new fake user and logged in under than user. Same behavior.
    • Started PC in Safe Mode. Unfortunately, in Safe Mode sleep functions are limited to the monitor and hard drives. Nothing to put the PC to sleep.
    • Tried going into sleep via Alt + F4. Same behavior.
    • powercfg -a reports S3 is active on my system.
    There are no obvious irregularities in Device Manager. The dongle shows up under USB Serial Bus Controllers as a USB Composite Device.
    • General Tab says "This device is working properly".
    • In Driver Tab, I tried searching for a better driver, but Windows says there is no better driver.
    • There is no Power Management tab.
    So as it turns out, all of things I've tried appear to have been a waste of time as it was not addressing the wireless function of the keyboard. I contacted the manufacturer and they suggested that I delete the USB Composite Device entry, re-boot and re-insert the dongle. However, that did not change inability to sleep the PC.

    Any other ideas?
     
    jaydub, Sep 10, 2022
    #4
Thema:

Using .vbs to sleep pc

Loading...
  1. Using .vbs to sleep pc - Similar Threads - Using vbs sleep

  2. PC stuck after using sleep mode

    in Windows 10 Gaming
    PC stuck after using sleep mode: HelloI put my computer in sleep mode yesterday and it responds to nothing, like it is dead. I have it plugged into a power outlet. What can I do? The power switch doesn't work.Lisa...
  3. PC stuck after using sleep mode

    in Windows 10 Software and Apps
    PC stuck after using sleep mode: HelloI put my computer in sleep mode yesterday and it responds to nothing, like it is dead. I have it plugged into a power outlet. What can I do? The power switch doesn't work.Lisa...
  4. PC stuck after using sleep mode

    in Windows 10 Performance & Maintenance
    PC stuck after using sleep mode: HelloI put my computer in sleep mode yesterday and it responds to nothing, like it is dead. I have it plugged into a power outlet. What can I do? The power switch doesn't work.Lisa...
  5. Using .vbs to sleep pc

    in Windows 10 Performance & Maintenance
    Using .vbs to sleep pc: So i'm using this command to put pc to sleep a vbs script. When I execute the command it signs me out but not sleep pc. Could you modify it so pc sleeps.Dim objShellSet objShell = CreateObject"Shell.Application"objShell.ShutdownWindowsset objShell = nothingSet WshShell =...
  6. Using .vbs to sleep pc

    in Windows 10 Software and Apps
    Using .vbs to sleep pc: So i'm using this command to put pc to sleep a vbs script. When I execute the command it signs me out but not sleep pc. Could you modify it so pc sleeps.Dim objShellSet objShell = CreateObject"Shell.Application"objShell.ShutdownWindowsset objShell = nothingSet WshShell =...
  7. VBS

    in Windows 10 Network and Sharing
    VBS: How do you make a vbs file open a file? https://answers.microsoft.com/en-us/windows/forum/all/vbs/9897f943-4d77-46e7-aeae-2e27d00f7937
  8. Vbs Error

    in Windows 10 Network and Sharing
    Vbs Error: I am getting an error "Microsoft VBScript runtime error '800a000d'" when trying to access a link on a trusted website https://answers.microsoft.com/en-us/windows/forum/all/vbs-error/6a6b54ea-f2c5-4106-9635-8b9d1a617f1f
  9. Any benefits to using TPM, VBS etc. as an average desktop PC user?

    in AntiVirus, Firewalls and System Security
    Any benefits to using TPM, VBS etc. as an average desktop PC user?: Hello everyone, This will most probably be a longer and somewhat unusual read; it's more of a discussion on this, I hope, than asking for help. It's also a part repost from the Technet forums, where nobody bothered to answer or even have an opinion. So here we go. I'm...
  10. VBS Script Renaming a pc script fails

    in Windows 10 Support
    VBS Script Renaming a pc script fails: can anyone tell me why this script fails with rc=5.. I am not very well versedin resolving scripts.... MUCH APPRECIATED IN ADVANCE! Const JOIN_DOMAIN = 1 Const ACCT_CREATE = 2 Const ACCT_DELETE = 4 Const WIN9X_UPGRADE = 16 Const DOMAIN_JOIN_IF_JOINED = 32 Const...