Archive: I just want to copy fileS


I just want to copy fileS
I need to distribute files to my customers. They are stored in the shared user folder

EX: C:\Users\Public\Documents\FOURLEAF\
\MACHINE\SAMPLE.CON
\MACHINE\OTHER.TMT
\FOLLOWER\SETTING\MAINFILE.SPT
The folder structure will always be the same (at least to start) as will the file extensions. The file names will vary with each customer. I would like to create an executable that will simply copy these files into the folders. Assume that the user will always have admin privileges.

I want the easist way to package up these files and send them to my customers. I have looked at other extracting tools and NSIS looks good for what I want.

Thanks

To learn NSIS, start with NSIS\Examples\Example1.nsi and Example2.nsi. Find out what all the commands do and why. (Use the command reference, http://nsis.sourceforge.net/Docs/Chapter4.html ) Once you've done that, you'll be well underway to being able to answer your own question(s).


I know that there are examples, and am capable of using them to teach myself the language. I just have such a simple case and want to get started that I hoped someone would be able to help.


If you need to package multiple files in the installer, how about just using a wildcard?
File "C:\Users\Public\Documents\FOURLEAF\MACHINE\*.CON"

Either way, these forums aren't about writing installers for other people, it's about helping people learning/using the language to solve specific issues. Particularly for beginners, this means we point to the manual whenever applicable - we prefer to teach people the proverbial fishing, rather than force-feed them.


Ok here is what I have so far....

; Basic.nsi
;
; This script will install mastercam machine definitions in standard locations

; The name of the installer
Name "MLC Post Installer"

; Output filname
OutFile "MLCPostSetup.exe"

Section "Copy"

; Change user context to ALL USERS
SetShellVarContext all

; Copy machine defs
SetOutPath "$DOCUMENTS\shared mcamx5\CNC_MACHINES\"
File *.control-5
File *.lmd-5
File *.mmd-5
File *.rmd-5

; Copy post files
SetOutPath "$DOCUMENTS\shared mcamx5\lathe\Posts"
File *.pst

SectionEnd


Now what I need a way to include the .lmd-5, .mmd-5, .rmd-5 only if they exist. There will only be on or the other files. Then I need to adjust where the "post" file get installed based on whether the .lmd-5, .mmd-5, or .rmd-5 files are included. The post file will be in ..\lathe\Posts for .lmd-5, ..\mill\Posts for .mmd-5 and ..\router\Posts for rmd-5.

Thanks

I think you want to do something like this...

!include LogicLib.nsh
...
; Copy machine defs
SetOutPath "$DOCUMENTS\shared mcamx5\CNC_MACHINES\"
File *.control-5
${If}{FileExists} *.lmd-5
File *.lmd-5
strcpy $0 lathe
${EndIf}
${If}{FileExists} *.mmd-5
File *.mmd-5
strcpy $0 mill
${EndIf}
${If}{FileExists} *.rmd-5
File *.rmd-5
strcpy $0 router
${EndIf}

; Copy post files
SetOutPath "$DOCUMENTS\shared mcamx5\$0\Posts"
File *.pst


The compiler will include the ?md-5 files for all three machine types (lathe, mill, router), but will only extract the one that has existing files. This won't work right for new installations; I'd recommend using the Component page to select mill/lathe/router and put each into its own section. You can use the radio button logic to be sure that only one gets selected.

Don

Thanks Don!

I am pretty full this week, but I will get back on it next week. Looks like it will work. It is always a difficult process learning a new language when you want to do the most basic stuff.:D

One question, you said it won't work for new installations? Is this if the folders do not exist? And could I do a check "if exists ...." to modify the behavior if the folder does not exist.

Of course this really shouldn't be a problem because that folder structure will ALWAYS be there.


The folder structure is not the problem (SetOutPath would create the structure), the problem is that the code needs to see existing files to decide which machine type you have (mill/router/lathe) and thus the correct files to extract.

Adding the component page and letting the user choose the machine would do it; you could detect their machine if the installation already exists and pre-set the components for them.

Don