问题
Basically I am trying to create an installer. I have an EXE file and I need to do the following steps through a bat file:
- create a folder at C:\Data
- Copy a file in C.\Data
- Create a folder inside C:\Program Files
- Copy exe file in C:\Program Files\My Project Folder
- Create shortcut to exe on Desktop
My code is as follows:
@echo off
if not exist "%PROGRAMFILES%\MyFolder" mkdir %PROGRAMFILES%\MyFolder
if not exist "C:\Data" mkdir C:\Data
copy /q /y ".\MyFile.exe" "%PROGRAMFILES%\MyFolder\MyFile.exe"
copy /q /y ".\MyFileDb.db" "C:\Data\MyFileDb.db"
The problem is that it shows "invalid path" error and says 0 files copied for MyFolder. However, it successfully creates Data folder and copies MyFileDb.db inside it.
Second problem is that I cannot figure out how to execute the Step 5 of my problem statement.
回答1:
MSI: I would use a proper MSI deployment tool. Here are some of the major ones.
- For something this simple I think the free version of Advanced Installer would work properly. It should be very simple. Maybe check the help portal and the videos.
- Then there is always WiX which is free and open source, but there is a learning curve.
- The Visual Studio Installer projects do work for simple things, but do not scale well. Free.
Non-MSI: You can also use non-MSI deployment technologies such as Inno Setup or NSIS.
Self-Extraction Tools: Some recommend self-extracting archives.
- I am very skeptical - essentially for practical-, runtime dependency- and security-reasons.
- Combine exe and msi file in one installer
Some Further Links:
- RoboCopy.exe: How do I compare two folders recursively and generate a list of files and folders that are different? A practical sample of using the newer RoboCopy.exe to do the copying.
来源:https://stackoverflow.com/questions/53130986/batch-file-giving-invalid-path-error-while-creating-an-installer