none
Create package to copy files to C:\Windows\System32\oobe\info\backgrounds

    Question

  • I have Windows 7 x64.

    I tried to create a SCCM package/program/collection/advertisement to distribute my default set of wallpapers to the following directory:

    C:\Windows\System32\oobe\info\backgrounds

    I use VBS for the script.

    When I execute the script using the advertisement it seems that I do not have enough right on the C:\windows\system32 directory to write the files. I I redirect the files to e.g. c:\test it is working normally, but redirecting them to C:\Windows\System32\oobe\info\backgrounds fails.

    Does someone know what I do wrong and how I can fix this ?

    Sunday, July 10, 2011 10:13 PM

Answers

  • I change the code to the following and now it is working.

    http://msdn.microsoft.com/en-us/library/aa384187%28v=VS.85%29.aspx

     

    OPTION EXPLICIT
    ON ERROR RESUME NEXT

    Dim gWshell, gFso, gSourceDir, gResultCode, gTempDir, gLogFile, gWinDir, gSystemDrive
    Dim gLog, gSysDir

    set gWShell = WScript.CreateObject("Wscript.Shell")
    Set gFso = CreateObject("Scripting.FileSystemObject")

    gTempDir = gWshell.ExpandEnvironmentStrings("%TEMP%")
    gWinDir = gWshell.ExpandEnvironmentStrings("%Windir%")
    gSystemDrive = gWshell.ExpandEnvironmentStrings("%SystemDrive%")

    If (PRG_Isx64) Then
        gSysDir = gWinDir & "\sysnative"
    Else
        gSysDir = gWinDir & "\SYSTEM32"
    End if

    gSourceDir = gFso.GetParentFolderName(WScript.ScriptFullName)

    gLogFile = gWindir & "\sources\logs\wallpapers.log"
    set gLog = gFso.CreateTextFile(gLogFile, True)

    '*****************************************
    '* Copy wallpapers
    '*****************************************
    gLog.Writeline "Copy wallpapers"
    if not gFso.FolderExists(gSysDir & "\oobe\info\backgrounds\") Then CreateFolder(gSysDir & "\oobe\info\backgrounds")
    gLog.Writeline " From : " & gSourceDir & "\Wallpapers\*.*"
    gLog.Writeline " To   : " & gSysDir & "\oobe\info\backgrounds"
    err.clear
    gFso.CopyFile gSourceDir & "\Wallpapers\*.*" , gSysDir & "\oobe\info\backgrounds", True
    gLog.Writeline " rc:" & err.number

    '*****************************************
    '* Copy default Other User icon
    '*****************************************
    gLog.Writeline "Copy default Other user icon"
    gLog.Writeline " From : " & gSourceDir & "\user.bmp"
    gLog.Writeline " To   : " & gSystemDrive & "\ProgramData\Microsoft\User Account Pictures\user.bmp"
    err.clear
    gFso.CopyFile gSourceDir & "\user.bmp" , gSystemDrive & "\ProgramData\Microsoft\User Account Pictures\user.bmp" , True
    gLog.Writeline " rc:" & err.number

    gLog.Close




    '***************************************************************************************
    '****************** START FUNCTION AREA ************************************************
    '***************************************************************************************

    Sub CreateFolder(strPath)
      If Not gFso.FolderExists(gFso.GetParentFolderName(strPath)) Then Call CreateFolder(gFso.GetParentFolderName(strPath))
      gFso.CreateFolder(strPath)
    End Sub

    Function PRG_Isx64
        if lcase(gWShell.Environment("SYSTEM")("Processor_Architecture")) = "amd64" Then
            PRG_Isx64 = True
        else
            PRG_Isx64 = False
        End if
    End Function


    • Marked as answer by pollewops Monday, July 11, 2011 8:21 AM
    Monday, July 11, 2011 8:15 AM

All replies

  • Are you running it as admin or as current user?  is this an x64 machine?  what is the error.

    Yes, you should be able to run a command that will copy a file to a folder.  If you are running it from the DP you can have a problem if you don't write the command correctly.  Are you downloading this to the local cache first?

     


    http://www.sccm-tools.com http://sms-hints-tricks.blogspot.com
    Monday, July 11, 2011 12:40 AM
  • This is my installation script.

    Within the package directory (gSourceDir), a subdirectiry is located called wallpapers containing the *.jpg files.

    Running the command from the local cache with the local admin account works perfect.

    Within the package is configured that the program should be run as ADMINISTRATOR. The OS on which the wallpapers needs to be installed is Windows 7 64 bit.

     

    OPTION EXPLICIT
    ON ERROR RESUME NEXT
    
    Dim gWshell, gFso, gSourceDir, gResultCode, gTempDir, gLogFile, gWinDir, gSystemDrive
    Dim gLog
    
    set gWShell = WScript.CreateObject("Wscript.Shell")
    set gFso = CreateObject("Scripting.FileSystemObject")
    
    gTempDir = gWshell.ExpandEnvironmentStrings("%TEMP%")
    gWinDir = gWshell.ExpandEnvironmentStrings("%Windir%")
    gSystemDrive = gWshell.ExpandEnvironmentStrings("%SystemDrive%")
    
    gSourceDir = gFso.GetParentFolderName(WScript.ScriptFullName)
    
    gLogFile = gWindir & "\sources\logs\wallpapers.log"
    set gLog = gFso.OpenTextFile(gLogFile,8,true)
    
    '*****************************************
    '* Copy wallpapers
    '*****************************************
    gLog.Writeline "Copy wallpapers"
    if not gFso.FolderExists(gWinDir & "\system32\oobe\info\backgrounds\") Then gFso.CreateFolder(gWinDir & "\system32\oobe\info\backgrounds\")
    gLog.Writeline gSourceDir & "\Wallpapers\*.*"
    gLog.Writeline gWinDir & "\system32\oobe\info\backgrounds"
    err.clear
    gFso.CopyFile gSourceDir & "\Wallpapers\*.*" , gWinDir & "\system32\oobe\info\backgrounds", true
    gLog.Writeline "rc:" & err.number
    
    '*****************************************
    '* Copy default Other User icon
    '*****************************************
    gLog.Writeline "Copy default Other user icon"
    err.clear
    gFso.CopyFile gSourceDir & "\user.bmp" , "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" , TRUE
    gLog.Writeline "rc:" & err.number
    
    gLog.Close
    
    
    
    
    '***************************************************************************************
    '****************** START FUNCTION AREA ************************************************
    '***************************************************************************************
    
    '##############################################################################################
    '# Create a folder (recursive)
    '##############################################################################################
    Sub CreateFolder(strPath)
     If Not gFso.FolderExists(gFso.GetParentFolderName(strPath)) Then Call CreateFolder(gFso.GetParentFolderName(strPath))
     gFso.CreateFolder(strPath)
    End Sub
    


     


    • Edited by pollewops Monday, July 11, 2011 7:05 AM
    Monday, July 11, 2011 6:56 AM
  • Some additional information. I now see that the *.jpg are copied, but are copied to "C:\Windows\SysWOW64\oobe\info\backgrounds" and not to "C:\Windows\System32\oobe\info\backgrounds"

    Something to do with 64 bit redirection ? And how can I solve this ?


    Monday, July 11, 2011 7:02 AM
  • I change the code to the following and now it is working.

    http://msdn.microsoft.com/en-us/library/aa384187%28v=VS.85%29.aspx

     

    OPTION EXPLICIT
    ON ERROR RESUME NEXT

    Dim gWshell, gFso, gSourceDir, gResultCode, gTempDir, gLogFile, gWinDir, gSystemDrive
    Dim gLog, gSysDir

    set gWShell = WScript.CreateObject("Wscript.Shell")
    Set gFso = CreateObject("Scripting.FileSystemObject")

    gTempDir = gWshell.ExpandEnvironmentStrings("%TEMP%")
    gWinDir = gWshell.ExpandEnvironmentStrings("%Windir%")
    gSystemDrive = gWshell.ExpandEnvironmentStrings("%SystemDrive%")

    If (PRG_Isx64) Then
        gSysDir = gWinDir & "\sysnative"
    Else
        gSysDir = gWinDir & "\SYSTEM32"
    End if

    gSourceDir = gFso.GetParentFolderName(WScript.ScriptFullName)

    gLogFile = gWindir & "\sources\logs\wallpapers.log"
    set gLog = gFso.CreateTextFile(gLogFile, True)

    '*****************************************
    '* Copy wallpapers
    '*****************************************
    gLog.Writeline "Copy wallpapers"
    if not gFso.FolderExists(gSysDir & "\oobe\info\backgrounds\") Then CreateFolder(gSysDir & "\oobe\info\backgrounds")
    gLog.Writeline " From : " & gSourceDir & "\Wallpapers\*.*"
    gLog.Writeline " To   : " & gSysDir & "\oobe\info\backgrounds"
    err.clear
    gFso.CopyFile gSourceDir & "\Wallpapers\*.*" , gSysDir & "\oobe\info\backgrounds", True
    gLog.Writeline " rc:" & err.number

    '*****************************************
    '* Copy default Other User icon
    '*****************************************
    gLog.Writeline "Copy default Other user icon"
    gLog.Writeline " From : " & gSourceDir & "\user.bmp"
    gLog.Writeline " To   : " & gSystemDrive & "\ProgramData\Microsoft\User Account Pictures\user.bmp"
    err.clear
    gFso.CopyFile gSourceDir & "\user.bmp" , gSystemDrive & "\ProgramData\Microsoft\User Account Pictures\user.bmp" , True
    gLog.Writeline " rc:" & err.number

    gLog.Close




    '***************************************************************************************
    '****************** START FUNCTION AREA ************************************************
    '***************************************************************************************

    Sub CreateFolder(strPath)
      If Not gFso.FolderExists(gFso.GetParentFolderName(strPath)) Then Call CreateFolder(gFso.GetParentFolderName(strPath))
      gFso.CreateFolder(strPath)
    End Sub

    Function PRG_Isx64
        if lcase(gWShell.Environment("SYSTEM")("Processor_Architecture")) = "amd64" Then
            PRG_Isx64 = True
        else
            PRG_Isx64 = False
        End if
    End Function


    • Marked as answer by pollewops Monday, July 11, 2011 8:21 AM
    Monday, July 11, 2011 8:15 AM