Solved

Logon script to copy WallPaper file depending the Resolution screen

Posted on 2011-03-08
3
1,296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
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 …

726 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