Solved

Logon script to copy WallPaper file depending the Resolution screen

Posted on 2011-03-08
3
1,291 Views
Last Modified: 2012-05-11
In other question I found the VBS to get the resolution of the screen
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21479950.html 

but now I need to know how to use the result of the VBS file to copy a Wallpaper file dependeing the resolution (I know, need to put a lot of posible combinations of screen resolutions)

or if can get the aspect ratio (4:3 or 16:9) can only copy 2 posible files

Have Windows 2008 R2 Domain, with clients XP and 7

Ideas are wellcome
0
Comment
Question by:DavidLeal
  • 3
3 Comments
 
LVL 3

Author Comment

by:DavidLeal
ID: 35070460
I'm pretty close to the solution, searching in google (and with help of a programer of the company)

get to this:

screen = ScreenResolution
WScript.Echo screen(0),screen(1)


Function ScreenResolution()
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Navigate("about:blank")
Do Until .readyState = 4: wscript.sleep 100: Loop
width = .document.ParentWindow.screen.width
height = .document.ParentWindow.screen.height
End With
oIE.Quit
ScreenResolution = array(width,height)
End Function

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")

If (screen(0)/screen(1)) > 1.5 Then
      filesys.CopyFile "c:\vbs\wall1280x800.jpg", "C:\wp4.jpg"
Else
      filesys.CopyFile "c:\vbs\wall800x600.jpg", "C:\wp4.jpg"
End IF


but now need insert %LOGONSERVER% and %USERPROFILE% variables in copy statements for the origin and destination paths to finish it

Why 1.5 ? 4:3 ascpect ratio was 1.3333 and 16:9 aspect ratio was 1.77777
0
 
LVL 3

Accepted Solution

by:
DavidLeal earned 0 total points
ID: 35071100
Ok, I solve my script.

Tested and work well

I don't remove the echo of the resolution in orther to know the resolution.
 
set objWShell=wScript.createObject("WScript.Shell")

screen = ScreenResolution
WScript.Echo screen(0),screen(1)

strProfile = objWShell.ExpandEnvironmentStrings("%USERPROFILE%")
strLogonServer = objWShell.ExpandEnvironmentStrings("%LOGONSERVER%")

Function ScreenResolution()
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Navigate("about:blank")
Do Until .readyState = 4: wscript.sleep 100: Loop
width = .document.ParentWindow.screen.width
height = .document.ParentWindow.screen.height
End With
oIE.Quit
ScreenResolution = array(width,height)
End Function

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")


If (screen(0)/screen(1)) > 1.5 Then
	strFileToCopy=strLogonServer&"\SYSVOL\geusa.corp\scripts\wall1280x800.jpg"
	strFolder=strProfile&"\wp4.jpg"
	filesys.CopyFile strFileToCopy,strFolder
Else
	strFileToCopy=strLogonServer&"\SYSVOL\geusa.corp\scripts\wall800x600.jpg"
	strFolder=strProfile&"\wp4.jpg"
	filesys.CopyFile strFileToCopy,strFolder
End IF

Open in new window

0
 
LVL 3

Author Closing Comment

by:DavidLeal
ID: 35083589
Reading other questions, and searching in google, I solve the Issue
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question