Batch file to enable: Extend my Windows desktop to my 2nd...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
anoble1
Posts: 22
Joined: 29 Nov 2012 10:24

Batch file to enable: Extend my Windows desktop to my 2nd...

#1 Post by anoble1 » 07 May 2013 12:18

Batch file to enable: Extend my Windows desktop to my 2nd monitor. I have a lot of users when they remote in, and when they come back they will only see 1 monitor. Is it possible to crate a batch file to automate this?

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch file to enable: Extend my Windows desktop to my 2n

#2 Post by Ed Dyreen » 13 May 2013 22:42

Hi anoble1,

Don't know the regKey/s that control that but u should be able to figure it out.
  • download regmon.EXE
  • go to display properties where you enable the setting but don't enable it just yet.
  • create a registry snapshot with regmon.
  • now enable that setting and press ok.
  • create another snapshot with regmon.
  • run 'compare snapshots' with regmon, you now should have the key/s that has/have changed
    ( you'll often get more than one key, but only one of them should be the one )
  • now manually change the keys to test if you've got the right one
    ( you'll have to relogon to see the effect )
  • Now write a batch that changes the key
  • Not sure if it'll work but try this to apply the setting without logging of and on:

Code: Select all

Rundll32.exe user32.dll,UpdatePerUserSystemParameters
Another less gentle way to try apply the new setting is terminating explorer.EXE then restarting it.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Batch file to enable: Extend my Windows desktop to my 2n

#3 Post by Ed Dyreen » 13 May 2013 23:23

Maybe VBScript

Code: Select all

Dim oWSH : Set oWSH = WScript.CreateObject( "WScript.Shell" )
oWSH.Run( "%systemroot%\system32\control.exe desk.cpl,@0,3" )
WScript.Sleep( 1000 ) : ' Give Display Properties time to load
oWSH.AppActivate( "Display Properties" )
oWSH.SendKeys( "{TAB}" )
oWSH.SendKeys( "2" )
oWSH.SendKeys( "%W" )
oWSH.SendKeys( "{ENTER}" )
WScript.Quit( 0 )
ps: normally I'd use taskList.EXE /nh /v /fo csv /fi "windowTitle eq Display Properties" instead of WScript.Sleep( 1000 ) but I'm feeling lazy :p

see ya,

Post Reply