创建安装程序时批处理文件给出无效的路径错误 [英] Batch file giving invalid path error while creating an installer

查看:45
本文介绍了创建安装程序时批处理文件给出无效的路径错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我正在尝试创建安装程序.我有一个EXE文件,我需要通过bat文件执行以下步骤:

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:

  1. 在C:\ Data创建一个文件夹
  2. 在C. \ Data中复制文件
  3. 在C:\ Program Files文件中创建一个文件夹
  4. 将exe文件复制到C:\ Program Files \ My Project文件夹中
  5. 在桌面上创建exe的快捷方式

我的代码如下:

@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"

问题在于它显示"无效的路径"错误,并指出为 MyFolder 复制了0个文件.但是,它成功创建了 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.

第二个问题是我无法弄清楚如何执行问题陈述的第5步.

Second problem is that I cannot figure out how to execute the Step 5 of my problem statement.

推荐答案

  1. MSI :我会使用适当的MSI部署工具. 以下是一些主要的 .

  • 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.

非MSI :您还可以使用 Inno Setup 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 :
  • 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.

这篇关于创建安装程序时批处理文件给出无效的路径错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆