localzuk Posted July 18, 2013 Posted July 18, 2013 I am trying to copy a file to the path in the title, using a vbs script. Basically, the vbs script detects the screen resolution on the machine, then copies a relevant jpg to the folder and names it backgroundDefault.jpg. Problem is, I cannot get it to run properly in an automated way. If I run it manually, as administrator, it works fine. How can I run this script properly as part of an OS deployment task sequence?
Gatt Posted July 18, 2013 Posted July 18, 2013 What error you getting? Do the Info\Backgrounds folders exist? Is this a 64bit PC? (it may be trying to put them into SysWow64) I did create an MSI (using VS2010) for doing this and for setting the registry keys - made it easer to deploy too
localzuk Posted July 18, 2013 Author Posted July 18, 2013 Not getting any errors that I can see. It just doesn't run properly. The script also checks for and creates the path if it doesn't exist. It is a 64bit PC - which is why I'm using a script. My MSI does what you'd expect, and sticks the files in the SysWOW64 folder instead. I didn't want to have to go about creating a full software project simply to copy a file to a folder - seems like over complicating it!
Gatt Posted July 18, 2013 Posted July 18, 2013 Theres something about how SCCM handles 32/64 bit - and it can be annoying - normal deployment types have an option for treating stuff as 32 bit when run on 64 bit systems - it affects system32 + syswow64 as well as the registry as well not sure about OSD though...
localzuk Posted July 18, 2013 Author Posted July 18, 2013 Ok, I'll take it back a step. Here's my script Set filesys = CreateObject("Scripting.FileSystemObject") Const PATH = "C:\Windows\System32\oobe\info\backgrounds\" BuildFullPath PATH Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0) For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight MsgBox(intHorizontal&"x"&intVertical) If filesys.FileExists("background"&intHorizontal&"x"&intVertical&".jpg") Then MsgBox("Yup - "&"background"&intHorizontal&"x"&intVertical&".jpg") filesys.CopyFile "background"&intHorizontal&"x"&intVertical&".jpg", PATH&"backgroundDefault.jpg" Else MsgBox("Nope - "&"background"&intHorizontal&"x"&intVertical&".jpg") filesys.CopyFile "background1280x1024.jpg", PATH&"backgroundDefault.jpg" End If Next Sub BuildFullPath(ByVal FullPath) If Not filesys.FolderExists(FullPath) Then BuildFullPath filesys.GetParentFolderName(FullPath) filesys.CreateFolder FullPath End If End Sub How should I be executing this? Package? Application? Other?
thesk8rjesus Posted July 18, 2013 Posted July 18, 2013 With this sort of thing I tend to create a package with no software just point it to the network path. Then in the task sequence add a command line item with the assigned package, and in the command line just put the name of the script. If it goes off to a network location in the script you will need to run the command line as specified user. This works for me
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now