Windows 7 How do I access the "SystemParametersInfo " function in a batch file?

Discussion in 'Programming and Scripting' started by TotallyAwesome, Jul 10, 2013.

  1. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,

    I would like to use the following function "SystemParametersInfo" in a batch file on a Windows 7 machine. Is it in a DLL somewhere?
     
  2. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
  3. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,

    Thanks for the response. I am migrating alot of computers from WIndows XP Pro to WIndows 7. Here is a example of one the things I am doing on the XP Pro machines

    :std_wallpaper
    echo "Start of Wallpaper change"
    REG ADD "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "0 0 255" /f
    REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "C:\Stonehenge.bmp" /f
    REM The following line refreshes the desktop.
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
    echo "Wallpaper change complete"
    goto :eof

    What I have discovered is that the following function/operation does not work in Windows 7
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
     
  4. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,
    Thanks for telling where "SystemParametersInfo" is located. So I write some small test code to try it out.
     
  5. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,

    I tried the following code in a short bat file

    echo "Start of Wallpaper change"
    REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "U:\Azul.bmp" /f
    :: The following line refreshes the desktop.
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll, SystemParametersInfo(SPI_SETDESKWALLPAPER)


    I get a error dialog box that says

    Error in user32.dll
    Missing entry:SystemParametersInfo(SPI_SETDESKWALLPAPER)

    It appear the the function does not exist in userdll.32
     
  6. Mike

    Mike Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Jul 22, 2005
    Messages:
    8,488
    Likes Received:
    783
    At the end:

    RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
     
  7. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,

    Thank you for the response to my request. I have made the changes you suggested and I am still getting the error dialogs. Here is the code segment

    echo "Start of Wallpaper change"
    REG ADD "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "U:\Azul.bmp" /f
    REM The following line refreshes the desktop.
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll,SystemParametersInfo(SPI_SETDESKWALLPAPER)
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters,1,True

    What am I missing here?
     
  8. Mike

    Mike Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Jul 22, 2005
    Messages:
    8,488
    Likes Received:
    783
    Remove:
    %SystemRoot%\System32\RUNDLL32.EXE user32.dll,SystemParametersInfo(SPI_SETDESKWALLPAPER)

    (Sorry, wrong answer... I tried your script. Back to the drawing board. Not sure what is wrong)
     
  9. Mike

    Mike Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Jul 22, 2005
    Messages:
    8,488
    Likes Received:
    783
    It appears this may have worked on previous versions of Windows but no longer.
     
  10. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    I'm able to run the function like this:

    Code:
    RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
    Please not the EXACT spacing, as it did not work if I deleted spaces between commas, etc...
     
  11. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    I will try that....hold on
     
  12. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Thanks for the tip on the exact spacing, etc. that eliminated one of the error dialogs. Still getting a error dialog from

    %SystemRoot%\System32\RUNDLL32.EXE user32.dll,SystemParametersInfo(SPI_SETDESKWALLPAPER)

    This is a WIndows 7 computer and the UpdatePerUserSystemParamters worked fine on XP Pro. it no longer works on WIndows 7
     
  13. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    When you say it doesn't work on 7 do you mean it gives you an error, or does not have the intended effect? It runs on my Windows 7 machine just fine, however I'm not trying to mess with the wallpaper to test if it actually functions.
     
  14. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,

    I should have clarified "it doesn't work". the desktop wallpaper does not change and I get a error dialog box. Soemthing happend with WIndows 7 that caused code not to work any more.
     
  15. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    What does the error dialog say?
     
  16. TotallyAwesome

    TotallyAwesome New Member

    Joined:
    Jul 9, 2013
    Messages:
    12
    Likes Received:
    0
    Hello,
    Here is the text from the error Dialog box when I run the script

    Error in user32.dll
    Missing entry: SystemParametersInfo(SPI_SETDESKWALLPAPER)


    The error message above implies that the "SystemParametersInfo" function is not contained in the user32.dll. Here is the code that calls the "SystemParametersInfo" function

    %SystemRoot%\System32\RUNDLL32.EXE user32.dll,SystemParametersInfo(SPI_SETDESKWALLPAPER)


    I hope this helps you help me figure out what is going on.
     
  17. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    It appears that Rundll32's syntax says the usage should be:

    rundll32.exe user32.dll,SystemParametersInfo Parm1 Parm2 Parm3

    Have you tried
    rundll32.exe user32.dll,SystemParametersInfo SPI_SETDESKWALLPAPER

    You may have to find the defined value for SPI_SETDESKWALLPAPER and use that instead...
     

Share This Page

Loading...