Client Management Suite

 View Only
  • 1.  how to copy file to multiple user roaming profiles?

    Posted Oct 23, 2014 09:23 PM

    I have an .ini file that I need to copy to users/[name]/appdata/roaming/imagenow folder (imagenow being the utilised application). However I need it to go to all EXISTING user profiles. I know %appdata% references the CURRENT logged in user, so that won't work as I need to copy the file to each users appdating/roaming folder.

    Anybody know how to go about doing this? I'm not well versed in vbscript.

     

    Thank you!

     

     

     



  • 2.  RE: how to copy file to multiple user roaming profiles?

    Posted Oct 24, 2014 01:32 AM

    Check the article

    https://www-secure.symantec.com/connect/downloads/script-copy-filesfolders-all-user-profiles-machine



  • 3.  RE: how to copy file to multiple user roaming profiles?

    Posted Oct 29, 2014 10:44 AM

    The article consoleadmin is useful.

     

    Here is the script I used to copy a single file ( java exceptions ) into each local profile.

    You would just have to alter the copyfile part for your use and ensure the source file is in same directory as script.

    I specifically excluded the script from looking/copying into default profile folders and since i was only targeting locally cached doamin profiles.

     

    On Error Resume Next
    Const OverwriteExisting = True
    Const strComputer = "."
    Const HKLM = &H80000002
    
    Dim StrDocandSettings,strSysDrive, strProfilePath
    Dim aryUser
    Dim oFSO, objShell, CurrentDir, oReg
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject( "WScript.Shell" )
    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
    strSysDrive=objShell.ExpandEnvironmentStrings("%SystemDrive%")
    strProgramFiles=objShell.ExpandEnvironmentStrings("%ProgramFiles%")
    strProgramData=objShell.ExpandEnvironmentStrings("%ProgramData%")
    CurrentDir = oFSO.GetParentFolderName(Wscript.ScriptFullName)
    
    oReg.GetExpandedStringValue HKLM, "Software\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory", strProfilePath
    If VarType(strProfilePath) = vbNull Then
        'wscript.echo "error: registry key not found"
        wscript.Quit(1)
    End If
    
    
    'Setting the environment for userprofile
    	
    If OSis7or8 Then
    	Set StrDocandSettings = oFSO.getFolder(strSysDrive & "\users")
    	'Taking all the folder under "users" or in "documents and settings"
    	Set aryUser = StrDocandSettings.SubFolders
    
    	'Restricting the user
    	For Each strUserName in aryUser
    
    		' Ignore All Users folder, Administrator profile, and system folders
    		If strUserName.Name <> "All Users" and strUserName.Name <> "Administrator" _
    		  And strUserName.Name <> "LocalService" And strUserName.Name <> "NetworkService" _
    		  And strUserName.Name <> "Default" And strUserName.Name <> "Public" _
    		  And strUserName.Name <> "Default User" And strUserName.Name <> "NetworkService" Then
    	
    			GeneratePath(strUsername & "\AppData\LocalLow\Sun\Java\Deployment\security")
    			oFSO.CopyFile CurrentDir & "\exception.sites" , strUsername & "\AppData\LocalLow\Sun\Java\Deployment\security\exception.sites" , True
    			
    		End If
    		
    	Next
    
    'XP Operating system
    Else
    	Set StrDocandSettings = oFSO.getFolder(strProfilePath)
    	'Taking all the folder under "users" or in "documents and settings"
    	Set aryUser = StrDocandSettings.SubFolders
    
    	'Restricting the user
    	For Each strUserName in aryUser
    	
    		' Ignore All Users folder, Administrator profile, and system folders
    		If strUserName.Name <> "All Users" and strUserName.Name <> "Administrator" _
    		  And strUserName.Name <> "LocalService" And strUserName.Name <> "NetworkService" _
    		  And strUserName.Name <> "Default" And strUserName.Name <> "Public" _
    		  And strUserName.Name <> "Default User" And strUserName.Name <> "NetworkService" Then
    	
    			GeneratePath(strUsername & "\Application Data\Sun\Java\Deployment\security")
    			oFSO.CopyFile CurrentDir & "\exception.sites" , strUsername & "\Application Data\Sun\Java\Deployment\security\exception.sites" , True
    			
    		End If
    	
    	Next
    
    End If
    
    
    WScript.Quit
    
    
    Function OSis7or8
    Dim WshShell, strVal
    Set WshShell = CreateObject("WScript.Shell")
    OSis7or8 = False
    On Error Resume Next
    strVal = WshShell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProductName")
    Err.Clear
    On Error Goto 0
    If Instr(LCase(strVal), "windows 7") > 0 Then
    OSis7or8 = True
    End If
    If Instr(LCase(strVal), "windows 8") > 0 Then
    OSis7or8 = True
    End If
    
    End Function
    
    
    Function GeneratePath(pFolderPath)
      GeneratePath = False
      If Not oFSO.FolderExists(pFolderPath) Then
        If GeneratePath(oFSO.GetParentFolderName(pFolderPath)) Then
          GeneratePath = True
          Call oFSO.CreateFolder(pFolderPath)
        End If
      Else
        GeneratePath = True
      End If
    End Function
    
    

     

     

    Any questions just ask.

     

    Thanks,

    Clay