Solved

Logon script to copy WallPaper file depending the Resolution screen

Posted on 2011-03-08
3
1,293 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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.
In-place Upgrading Dirsync to Azure AD Connect
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
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 …

840 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