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

#1
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?
 


Josephur

Windows Forum Admin
Staff member
Premium Supporter
#2
Can you be more specific on what your doing? If you want to call an API call from the command line you may need to use something like: http://betanews.com/2011/07/13/take-control-of-batch-files-with-winapiexec/

The specific call you mentioned is in user32.dll, see: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx
 


#3
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
Hello,
Thanks for telling where "SystemParametersInfo" is located. So I write some small test code to try it out.
 


#5
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
 


Mike

Windows Forum Admin
Staff member
Premium Supporter
#6
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
At the end:

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


#7
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?
 


Mike

Windows Forum Admin
Staff member
Premium Supporter
#8
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)
 


Mike

Windows Forum Admin
Staff member
Premium Supporter
#9
It appears this may have worked on previous versions of Windows but no longer.
 


Josephur

Windows Forum Admin
Staff member
Premium Supporter
#10
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
I will try that....hold on
 


#12
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
 


Josephur

Windows Forum Admin
Staff member
Premium Supporter
#13
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
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.
 


Josephur

Windows Forum Admin
Staff member
Premium Supporter
#15
What does the error dialog say?
 


#16
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.
 


Josephur

Windows Forum Admin
Staff member
Premium Supporter
#17
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...
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.