how do I extend my desktop to a 2nd monitor, using a script?

I would like  script to extend my desktop to a 2nd monitor. I frequently take my laptop from home and work. I would like to not have to manually switch it by right clicking on the desktop, what a pain. Is there a windows API command or a .NET command that would do this for me? The solution could be written as a VBscript, or windows script, or in .NET. or a 3rd party app.

I found this blog which was useful, but I wonder if there is a better, more reliable way. I don't really like scripting against the GUI (using autoIT). It is not a very safe thing to do in my opinion.

I'd really appreciate the help!
Who is Participating?
If you have nvidia this should do the trick

for dual view
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("rundll32.exe nvcpl.dll,dtcfg setview 1 dualview")

for single display
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("rundll32.exe nvcpl.dll,dtcfg setview 1 normal")

more information about nvcpl.dll can be found here
brokeMyLegBikingAuthor Commented:
beautiful! you are my new best friend!

Loads of thanks, bloody brilliant. (Sorry, I'm reading Harry Potter 7 right now).


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.