Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


MitsuMan

Copy file to all users

10 posts in this topic

Hello

i would like to know hot it is possbile to copy a file to all users in windows 7

I have found one on the net but it dont work

'==========================================================================

' AUTHOR: Eshwar

' DATE : 12/12/2008

' COMMENT: This script will copy source files/folders to each user profile on the machine

'==========================================================================

'On Error Resume Next

'DECLARE VARIABLES HERE

Dim fso

Dim oFolder1, objFolder, oFolder

Dim path

Dim WSHShell

Dim colFolders

Dim sDocsAndSettings

Dim strComputer

strComputer = "."

Set WSHShell = CreateObject("WScript.Shell")

Set fso = createobject("Scripting.FileSystemObject")

'SPECIFY THE PATH OF THE FOLDER IN WHICH SOURCE FILES RESIDE

Set oFolder1 = fso.GetFolder("c:\MyFolder")

'COPY FILES TO USER PROFILES

sDocsAndSettings = "C:\Users\"

Set colFolders = fso.GetFolder(sDocsAndSettings)

For Each oFolder In colFolders.SubFolders

Select Case LCase(oFolder.Name)

Case "admin", "administrator", "newuser", "all users", "default user.original", "localservice", "networkservice"

'LEAVE THE DEFAULT PROFILES ON THE MACHINE

Case Else

' Check for the path

If fso.FolderExists(sDocsAndSettings & oFolder.Name & "\AppData") Then

'COPY FOLDER TO USER PROFILE

fso.CopyFolder oFolder1, sDocsAndSettings & oFolder.Name & "\AppData\Roaming\IDMComp\UltraEdit" ,True

End If

End Select

Next

Set fso = Nothing

Set WSHShell = Nothing

0

Share this post


Link to post
Share on other sites
COPY MyFile.ext %PUBLIC%

0

Share this post


Link to post
Share on other sites

COPY MyFile.ext %PUBLIC%

So you mean if i do this it should work

COPY MyFile.ext C:\Users\%PUBLIC%\AppData\Roaming\IDMComp\UltraEdit

So then it will copy to 3 diffrent user.

C:\Users\Test 1\AppData\Roaming\IDMComp\UltraEdit

C:\Users\Test 2\AppData\Roaming\IDMComp\UltraEdit

C:\Users\Test3\AppData\Roaming\IDMComp\UltraEdit

0

Share this post


Link to post
Share on other sites

I don't think that the response I provided is suitable for the example you've now provided.

The following untested powershell script may work for you.

$PathToMyFile = "MyFile.ext"
$UserProfiles = GWmi Win32_UserProfile -filter "LocalPath Like '%\\Users\\%'" | Select-Object -ExpandProperty LocalPath
ForEach ($Profile in $UserProfiles) {
Copy-Item $PathToMyFile -Destination "$Profile\AppData\Roaming\IDMComp\UltraEdit"
}

0

Share this post


Link to post
Share on other sites

I don't think that the response I provided is suitable for the example you've now provided.

The following untested powershell script may work for you.

$PathToMyFile = "MyFile.ext"
$UserProfiles = GWmi Win32_UserProfile -filter "LocalPath Like '%\\Users\\%'" | Select-Object -ExpandProperty LocalPath
ForEach ($Profile in $UserProfiles) {
Copy-Item $PathToMyFile -Destination "$Profile\AppData\Roaming\IDMComp\UltraEdit"
}

Hello

I have try to make it now but it dont work or copy anything.i try to attach the script to here

but i am not allow to attach these type of files even with winrar

PS C:\test> test.ps1

The term 'test.ps1' is not recognized as the name of a cmdlet, function, script

file, or operable program. Check the spelling of the name, or if a path was in

cluded, verify that the path is correct and try again.

At line:1 char:9

+ test.ps1 <<<<

+ CategoryInfo : ObjectNotFound: (test.ps1:String) [], CommandNot

FoundException

+ FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command test.ps1 was not found, but does exist in th

e current location. Windows PowerShell doesn't load commands from the current lo

cation by default. If you trust this command, instead type ".\test.ps1". See "ge

t-help about_Command_Precedence" for more details.

PS C:\test>

Thank you very much for helping.

Edited by MitsuMan
0

Share this post


Link to post
Share on other sites
C:\test> .\test.ps1
0

Share this post


Link to post
Share on other sites
C:\test> .\test.ps1

Then i get this

$PathToMyFile = "Uedit32.ini"

$UserProfiles = GWmi Win32_UserProfile -filter "LocalPath Like '%\\Users\\%'" | Select-Object -ExpandProperty LocalPath

ForEach ($Profile in $UserProfiles) {

Copy-Item $PathToMyFile -Destination "$Profile\AppData\Roaming\IDMComp\UltraEdit\"

}

0

Share this post


Link to post
Share on other sites

  • Open Powershell as Administrator
  • Type/Enter Set-ExecutionPolicy Unrestricted
  • Try again!

<Edit>You may find that an ExecutionPolicy of RemoteSigned is better for you.<Edit>

Edited by Yzöwl
See <Edit />
0

Share this post


Link to post
Share on other sites

Hello

the script seems to work now

Can you make so in the script it auto makes this also

Open Powershell as Administrator

Type/Enter Set-ExecutionPolicy Unrestricted

so i dont need to do it. i would like to try the script with wpi and see if it works there but the

script dont work before i have set the policy.

0

Share this post


Link to post
Share on other sites

The setting of the execution policy is a one time only deal in normal use.

You have decided however to now incorporarte this script as part of a WPI install; That is not something which necessitates the editing of my script.

WPI can utilise the running of powershell scripts, you can set the execution policy to unrestricted prior to running this script. Search the WPI Forum for more information on how to do this.

Are you sure that you are using WPI to install on an already running system with several users already configured with the application data directories you're intending to add to?

0

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.