Copy File Users APPDATA Folders

Hello everyone,

I need to copy some configuration files for IBM Client Access to all the users’ appdata folder on serveral Windows7 clients and then create a link to the system on everyone desktop.

I try to explain with an example :blush: :

I need these 3 files SEPE.WS , SEPE.OWS, SEPE.CAE in all the appdata sub-folders

\APPDATA\ROAMING\IBM\CLIENT ACCESS\EMULATOR\PRIVATE\

For what concern the *.AS4 icon there is no problem, I’ve already done it however I do have a problem figuring out how should I proceed with the copy of files : I’ve found a Topicwhere someone was trying to copy some files to the current logged user but I don’t know if this is what I need. My question is : if I use this what is stated in the topic I’ve linked above will it work for my case or do I need something specific ? Since it seems it works only for logged user I think not, because I need that the configuration files must be in every user appadata subfolder whether the user is logged or not.

If you need more informations let me know.

I would probably approach this with a policy action (an action with no expiration date, set to reapply whenever it became relevant) that copied these files to that folder for whoever the current logged in user is. The relevance of the fixlet would need to reference whether the files existed in the current logged in user’s AppData path. Your reapplying fixlet would then catch any users for which the files didn’t exist next time they log in and put them there.

Presumably you could also kick off a Powershell script to iterate through every folder and copy the files there. I don’t know enough about the program to know whether it makes a difference if the files are there on login (even for new users?), but assuming not, the policy action I describe above would probably be my first stab at it.

Yeah, I thought the same, a policy action was on my to do list after a few tests.

For now my script create 3 files in the appdata folders referring (?) to the current logged user. It creates the files properly but I didn’t think about a PS Script to pass through every user and create the files.

I’ll give it a try

maybe you can change *.ini file to use global file. herewith you can use program data folder.

You can do this natively in actionscript as well.

  1. Find the Profiles folder

q: values "ProfilesDirectory" of keys "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry A: %25SystemDrive%25\Users%00 T: 0.081 ms I: plural registry key value

  1. substitute the environment variables in it

q: expand environment strings of (values "ProfilesDirectory" of keys "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string) A: C:\Users T: 0.102 ms I: plural string

  1. Find the users beneath it

q: folders of folders (expand environment strings of (values "ProfilesDirectory" of keys "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string)) A: C:\Users\Administrator A: C:\Users\All Users A: C:\Users\Default A: C:\Users\Default User A: C:\Users\Default.migrated A: C:\Users\jwalker A: C:\Users\Public

  1. build a batch file containing command lines to copy the file to each target user/folder. “%0d%0a” is the Carriage Return / Line Feed, so it makes each entry a separate line in the output file

q: concatenation "%0d%0a" of ("copy /y __Download\myfile %22" & pathname of it & "\appdata\mytargetfolder\mytargetfile%22") of folders of folders (expand environment strings of (values "ProfilesDirectory" of keys "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string)) A:copy /y __Download\myfile "C:\Users\Administrator\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\All Users\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\Default\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\Default User\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\Default.migrated\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\jwalker\appdata\mytargetfolder\mytargetfile"%0d%0acopy /y __Download\myfile "C:\Users\Public\appdata\mytargetfolder\mytargetfile"

Put that into an appendfile, rename it to a batch, and you should be good to go.

2 Likes

Hello! Thank you for all the replies. I have found a problem it seems that the SYSTEM user can’t write in this particular folder C:\Users*user_name*\AppData\Roaming\IBM\Client Access\Emulator\private although it has the permission… I need to write in this particular folder because I have to put in there some configuration files, and I can’t.

Do you know any way to bypass this kind of block ?

My Action does this :

// icon creation (executable)
delete __createfile
createfile until fine
[CA400SYSTEM]
CA400ENV=
SystemName=SEPE
DefaultView=3
OtherViewCmd=
OtherViewMenu=
5250Profile={concatenation of "c:\users" & name of current user & “\AppData\Roaming\IBM\Client Access\Emulator\private\SEPE.ws”}
fine
delete {concatenation of "c:\users" & name of current user & “\Desktop\SEPE.as4”}
copy __createfile {concatenation of "c:\users" & name of current user & “\Desktop\SEPE.as4”}

//creating configuration files
delete __createfile
createfile until fine
[Profile]
ID=WS
Description=
Version=9
[Translation]
IBMDefaultView=Y
DefaultView=
IBMDefaultDBCS=Y
DefaultDBCS=
[Communication]
AutoConnect=Y
Link=telnet5250
Session=5250
ForceConfigPanel=N
[Telnet5250]
HostName=SEPE
Security=CA400
LastConfigHostDoesNotTimeout=N
SSLClientAuthentication=Y
SecurityProtocol=TLS11
CertSelection=AUTOSELECT
[Edit]
TrimRectSizingHandles=N
[Telnet3270]
LastConfigHostDoesNotTimeout=N
[Telnet5250SPX]
LastConfigHostDoesNotTimeout=N
[TelnetASCII]
LastConfigHostDoesNotTimeout=N
[5250]
ScreenSize=27x132
HostCodePage=1144-I
BypassSignon=Y
PrinterType=IBM3812
[Keyboard]
CuaKeyboard=2
Language=Italy(141)
IBMDefaultKeyboard=N
DefaultKeyboard={concatenation of "c:\users" & name of current user & “\AppData\Roaming\IBM\Client Access\Emulator\private\AS400.KMP”}
[LastExitView]
fine
delete {concatenation of "c:\users" & name of current user & “\Desktop\SEPE.ws”}
copy __createfile {concatenation of "c:\users" & name of current user & “\Desktop\SEPE.ws”}

delete __createfile

delete {concatenation of "c:\users" & name of current user & “\AppData\Roaming\IBM\Client Access\Emulator\private\SEPE.ws”}
copy {concatenation of "c:\users" & name of current user & “\Desktop\SEPE.ws”} {concatenation of "c:\users" & name of current user & "\AppData\Roaming\IBM\Client Access\Emulator\private"}

I know that I could have created the file directly inside the intended folder But I was trying to create it first on desktop then moving it where I wanted… and it doesn’t work.

Any suggestion ?

I’m not really sure why you want to put the file on the user’s desktop as well, but

concatenation of “c:\users” & name of current user & “\Desktop\SEPE.ws”

should be

concatenation of “c:\users\” & name of current user & “\Desktop\SEPE.ws”

You have the folder delimiter after c:\users missing in several places in your script

1 Like

It seems that when posting the script the last \ after c:\users is removed… don’t know why.