Changing Wallpaper With VB

I'm trying to find/make a vb script ( .vbs file for win xp) that will change the Windows Desktop background (for current user only). I am new to VB so any help anyone could give would be nice. Hope someone can/may/will help.
-Wolfe
[237 byte] By [Phoenixwolfe] at [2008-2-2]
# 1
Phoenix wolfe wrote:
I'm trying to find/make a vb script ( .vbs file for win xp) that will change the Windows Desktop background (for current user only). I am new to VB so any help anyone could give would be nice. Hope someone can/may/will help.
-Wolfe

Phoenix,

Unfortunately, the only way to access this information in VB script is to use the WMI classes, specifically the Win32_Desktop class. However, the Wallpaper property for this class is read-only, so you can't set it in your script.

The only way I can think of doing this would be to write a COM object which would call the API, and then call that from your VB script. However, if you are going to go that far, you might as well write a small application to do it.

Hope this helps.

- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

casperOne at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
have any suggestions for how to learn com objects calling the api from vb? Ie: book titles isbn's etc etc.. And yes, i probably will end up writing a small app to do this, though id really rather not. I'm downloading visual studio 2003 and will intall that tonight, as well as download afew books on com objects.
anyway thanks :}
Phoenixwolfe at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
Phoenix wolfe wrote:
have any suggestions for how to learn com objects calling the api from vb? Ie: book titles isbn's etc etc.. And yes, i probably will end up writing a small app to do this, though id really rather not. I'm downloading visual studio 2003 and will intall that tonight, as well as download afew books on com objects.
anyway thanks :}

Phoenix wolfe,

If you are installing VS.NET 2003, then I would recommend that you just use VB.NET to create your app to do this. To try and do it through script isn't worth it.

- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

casperOne at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
If you do want to go down the dot net route check out the following sample on codeproject. It's c# but it will give you an idea of the classes / namespaces you need and what the structure of the code should be like.
http://www.codeproject.com/csharp/WallChange.asp
SimonGeering at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
I have 2003 .net on a disk now, but am using vb6. there are afew samples for vb6 that do what i want, just with alot more blunk. i didnt want the need for an exe but if i must then eh owell, i dont mind the trouble as long as it works.
I'm curious as to how hard it would be to make a dll that would do this or just use one thats already there? The whole point of this thing is so i can have mirc change xp's wallpaper... so its not really too important how it gets done.
Phoenixwolfe at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6
Phoenix,

Here is another code snippet you can try in your VB.NET application .EXE (see link):

http://www.devcity.net/Articles/119/vb2005_wallpaper.aspx

Jay and I worked on this code for a demo where we take wallpaper from the Movie Collection starter kit Wink

hope that helps,
Paul

PaulYuk_MS at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...