Solved

Logon script to copy WallPaper file depending the Resolution screen

Posted on 2011-03-08
3
1,288 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
Comment Utility
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
Comment Utility
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
Comment Utility
Reading other questions, and searching in google, I solve the Issue
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now