简体   繁体   English

文件名、目录名或卷 label 语法不正确,c#

[英]The filename, directory name, or volume label syntax is incorrect, c#

i've written a console application deploy.exe which runs a batch script.我编写了一个运行批处理脚本的控制台应用程序 deploy.exe。

Process p1 = new Process();
p1.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "installer.bat";
p1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p1.Start();
p1.WaitForExit();
p1.Close();

the installer.bat conatins the following command. installer.bat 包含以下命令。 \shared1\lists\list1.cmd \shared1\lists\list1.cmd

If i run the executable byitself it runs successfully.如果我自己运行可执行文件,它会成功运行。

However i needed it to run in a windows installer project.但是我需要它在 windows 安装程序项目中运行。 So i made a setup and deployment project and added the deploy.exe successfully as custom action upon install.所以我做了一个设置和部署项目,并在安装时成功添加了 deploy.exe 作为自定义操作。

It runs fine but when it starts to execute the command i get this error "The filename, directory name, or volume label syntax is incorrect".它运行良好,但是当它开始执行命令时,我收到此错误“文件名、目录名或卷 label 语法不正确”。 any help?有什么帮助吗?

the error seems to be inside the script which was being executed.错误似乎在正在执行的脚本中。 It contained environment variables %kind%, which were not acceptable by the installer for some reason.它包含环境变量 %kind%,由于某种原因,安装程序不能接受。 So it was working properly outside the installer and not properly when the installer was calling it.所以它在安装程序之外正常工作,而在安装程序调用它时却不能正常工作。

Try printing out what the value of AppDomain.CurrentDomain.BaseDirectory is.尝试打印出AppDomain.CurrentDomain.BaseDirectory的值。 It may not be where installer.bat is when you are installing it.当您安装它时,它可能不在installer.bat所在的位置。

Also, you tried adding the bat file to a custom action (if that is even possible)?此外,您尝试将 bat 文件添加到自定义操作(如果可能的话)?

And, would it possible to move what is in the bat to the exe?而且,是否可以将 bat 中的内容移动到 exe 中?

Is it a problem in your batch file?你的批处理文件有问题吗?

Check this:检查这个:

\\shared1\\lists\\list1.cmd

should probably be应该是

\\shared1\lists\list1.cmd

Note the extra \ chars in your original command.请注意原始命令中的额外 \ 字符。 That would cause the batch file to give that error.这将导致批处理文件给出该错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#OpenFileDialog:文件名,目录名称或卷标签语法不正确 - C# OpenFileDialog: The filename, directory name, or volume label syntax is incorrect 如何解决异常System.IO.IOException: 'the filename, directory name, or volume label syntax is incorrect in C#? - How to resolve the exception System.IO.IOException: 'the filename, directory name, or volume label syntax is incorrect in C#? windres:文件名,目录名或卷标签语法不正确 - windres: The filename, directory name, or volume label syntax is incorrect 文件流 - 文件名、目录名或卷 label 语法不正确 - Filestream - The filename, directory name, or volume label syntax is incorrect 文件名,目录名或卷标语法不正确,File.Copy - The filename, directory name, or volume label syntax is incorrect, File.Copy 文件名、目录名或卷 label 不正确 - The filename, directory name or volume label is incorrect 文件名,目录名称或卷标签语法不正确。 (来自HRESULT的异常:0x8007007B) - The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B) 如何修复System.Net.WebException:'文件名,目录名或卷标签语法不正确 - How do I fix System.Net.WebException: 'The filename, directory name, or volume label syntax is incorrect protoc-gen-grpc 文件名、目录名或卷标语法不正确 - protoc-gen-grpc The filename, directory name, or volume label syntax is incorrect FtpClient.GetListing(path)返回“文件名,目录名或卷标签语法不正确” - FtpClient.GetListing(path) returns “The filename, directory name, or volume label syntax is incorrect”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM