need batch file to disable screen saver

Discussion in 'Software' started by red death68, Aug 22, 2010.

  1. red death68

    red death68 Command Sergeant Major

    ok the deal is i got a new controller for my pc to use with my emulator for ps2 the problem is now my screen saver kicks on while im playing which as you can guess is a real nucience so im wondering

    first is it possible to disable my screen saver when i open my program and eneble it again once i close my program?

    second if it is possible can it be done with a batch file?

    ps:german i know youll probably see this so please be merciful and help im clueless when it comes to changing system settings it took forever to get used to copy and paste variables lol (im a batch nub)
     
  2. GermanOne

    GermanOne Guest

    Finally settings into the registry are responsible for the screensaver.
    Have a look at HKEY_CURRENT_USER\Control Panel\Desktop
    The value ScreenSaveActive is 0 for disabled and 1 for enabled. But if you change it manually (or by batch) it will probably not work because it will not update your system automatically.
    We could use a trick. In value SCRNSAVE.EXE you will find the full name of your screensaver. If you change the extension in data from *.scr to eg. *.sc_ the system cannot find it.

    I'm currently in China and have no time to make some tests today. Tomorrow I will write the code. Should be easy: REG QUERY to read the current data, REG ADD to change it, call your program, change the data back to the former value.

    Regards
    GermanOne
     
  3. red death68

    red death68 Command Sergeant Major

    that would be a great help if you could right the code with my luck in end up screwing up my system.....

    btw what you doing in china? vacation?
     
  4. GermanOne

    GermanOne Guest

    Here it comes. Tried it on XP.
    Code:
    @echo off &setlocal
    for /f "tokens=2* delims=	" %%a in ('reg query "HKCU\Control Panel\Desktop" /v "SCRNSAVE.EXE"') do set "original=%%b"
    reg add "HKCU\Control Panel\Desktop" /v "SCRNSAVE.EXE" /d "%original:~,-1%_" /f >nul
    
    :: change to your program:
    start "" /wait "C:\your\path\to\app.exe"
    
    reg add "HKCU\Control Panel\Desktop" /v "SCRNSAVE.EXE" /d "%original%" /f >nul
    
    Note:
    The sign behind delims= must be a TAB. Some forum software do not show it correctly.
    Never close the batch window, you will lose the former registry setting. It is closed automatically if you quit your program.

    To answer your question:
    No, I'm not on vacation. Our company opened a plant near Shanghai. Now I'm here to help the guys starting serial production and to endure the customer audits... but its such a tropical climate here. pooh

    Regards
    GermanOne
     
  5. red death68

    red death68 Command Sergeant Major

    lol cool whats ur company?

    and i take it un like it kinda cold?

    well it worked after i alterd program path a bit i just need to see if screen saver kicks on but im a little busy right now lol
     
  6. red death68

    red death68 Command Sergeant Major

    ok i had time tested it and screensaver still kicked on during my game i think main problem is it doesnt recognize my controller as an input device so screen savers axctivating since i never had this problem with my keyboard when i was using it as a controller
     
  7. GermanOne

    GermanOne Guest

    OK, did you check the registry value by regedit.exe? Is there a value called "SCRNSAVE.EXE" and what data is it? Maybe I'm wrong and we have to change other data.

    Btw. I don't wanna make advertising. It's a big company for tires, cooling hoses for cars and other automotve rubber products.
    Currently we have 35°C (95°F). This is not much, but the air is verry humid and there is a lot of smog.

    Regards
    GermanOne
     
  8. red death68

    red death68 Command Sergeant Major

    no i didnt

    which data specificly do you want string data or bianary

    sounds like s pretty successful buissness but the enviornment sounds horrid
     
  9. The Shadow

    The Shadow Specialist

    I'm sure someone will think this to be trivial, but
    we've really not needed screen savers since the day of the monochrome monitor.
    So, since screen savers can be such a PITA, I just turn them all off.
    End of problem, end of post.

    Cheers Mates!
    Shadow :cool
     
  10. GermanOne

    GermanOne Guest

    @The Shadow
    I totally agree with you. I only activated it for tests and after that I deactivated it immediately. Screen savers are bugging me too.

    @red death68
    The data type of "SCRNSAVE.EXE" is REG_SZ, so it must be a string.
    Run the following batch file and send me the content of reg.txt by PM.
    Code:
    >reg.txt reg query "HKCU\Control Panel\Desktop"
    
    Regards
    GermanOne
     
  11. The Shadow

    The Shadow Specialist

    I was doing some Googling on the topic of "Toggle Screen Saver" and found this interesting site.
    http://pcworld.about.com/magazine/2210p170id117423.htm

    Using this info, I'd write two little .reg scripts, to turn off the screensaver and then later turn it back on.

    I hope this is helpful

    Shadow :cool
     
  12. GermanOne

    GermanOne Guest

    Tried it similar. Read my first reply, I said the same but this doesn't work for me. Think the system will not update automatically. When I tried to restart the computer it worked.
    In a batch code you could write it as follows
    Code:
    @echo off &setlocal
    reg add "HKCU\Control Panel\Desktop" /v "ScreenSaveActive " /d "0" /f >nul
    
    :: change to your program:
    start "" /wait "C:\your\path\to\app.exe"
    
    reg add "HKCU\Control Panel\Desktop" /v "ScreenSaveActive " /d "1" /f >nul
    
    Regards
    GermanOne
     
  13. red death68

    red death68 Command Sergeant Major

    im using an older monitor so i kinda need screensave especialy since i have a bad habit of leaving the monitor on and walking away lol

    is your pm's disabled?

    ill try this one as well
     
  14. GermanOne

    GermanOne Guest

    Sorry, PM was disabled. I never noticed it. After registration I never had a look at my profile settings.:-o

    Regards
    GermanOne
     
  15. GermanOne

    GermanOne Guest

    OK, I analyzed the content of your sent file. Seems to be absolutely normal. All values are existing and no special characters are in the path or name. So I cannot help you with batch.

    There is an ugly way using VBScript.
    You could use the Run Method and the SendKeys Method to simulate changing the settings manually.
    Save as .vbs
    Code:
    Set oWSH = CreateObject("WScript.Shell")
    oWSH.Run "rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1", 1, False
    WScript.Sleep 1000
    oWSH.SendKeys "{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}{UP}~"
    WScript.Sleep 1000
    
    oWSH.Run """C:\somewhere\your\app.exe""",, True
    
    oWSH.Run "rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1", 1, False
    WScript.Sleep 1000
    oWSH.SendKeys "{DOWN}{DOWN}{DOWN}~"
    
    {UP} is for Arrow UP, {DOWN} is for Arrow Down, ~ is for Enter.
    So I wrote 15 Arrow Ups, this is probably enough to come to the first item (no screensaver).
    You have to change the path to your program and you have to figure out how many Arrow Down key strokes you need to come back to your screensaver (try it by hand in the context menu of the desktop).

    Regards
    GermanOne
     
  16. red death68

    red death68 Command Sergeant Major

    k thanks anyways i was hoping for the batch bhut o well thanks for ur time german

    ps: outa curiosity is there a way to make it refresh the setting so to speak like renew comand in cmd when involving ip?
     
  17. GermanOne

    GermanOne Guest

    No, unfortunately no way to refresh the settings. I remember there was a chance in the past using rundll32, but since XP it doesn't work anymore.
    Don't be shy, VBS is not complicated ;)

    EDIT Wait, what are you talking about? You try to change the IP Address or...

    Regards
    GermanOne
     
  18. red death68

    red death68 Command Sergeant Major

    true but my bro tried a vbs script for disabling cmd and his system has all sorts of issues now and wont open cmd on admins account anymore
     
  19. GermanOne

    GermanOne Guest

    lolz My VBS file will not disable cmd. Try manually what the code will do.
    BTW You could send me your brothers VBS code. I'm sure ther is a simple way to enable cmd. ;)
     
  20. red death68

    red death68 Command Sergeant Major

    ill send it if he even still has it on the system he may have deleted it in frustration
     
  21. Synetech

    Synetech Private E-2

    The reason that changing the registry setting does not work is because all that is happening is that the setting is being changed; Windows (and the actual windows and apps) are not notified of the change until the shell (Explorer) is restarted (or the system is rebooted). Alternately, you could try broadcasting the WM_SETTINGCHANGE message to all top-level windows via HWND_BROADCAST.
     
  22. GermanOne

    GermanOne Guest

    True. But did you read the topic ;) Would you think you could use these functions in a batch code? No way!
    However, since I know that red death68 is about to learn Java he could possibly apply your suggestion.

    Regards
    GermanOne
     
  23. Synetech

    Synetech Private E-2

    I don’t see why not. Some time back, I wrote an EXE that simply broadcasts the WM_SETTINGCHANGE message to all top-level windows. I use it mostly in batch files after importing REG files that make changes to the environment variables.

    Alternately, it can be done in one of the VB scripts mentioned previously.
     
  24. GermanOne

    GermanOne Guest

    You cannot call these functions in an batch file or in a VBScript directly. You need a third party tool or you have to write your own in a progamming language where these functions are available.

    Regards
    GermanOne
     
  25. Synetech

    Synetech Private E-2

    I just did a quick Google, but it does look like there is a PostMessage/SendMessage function available to VBS.
     
  26. GermanOne

    GermanOne Guest

    Not at all.
    It's available to other VB dialicts (VB, .NET, VBA ...).

    Regards
    GermanOne
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds