简体   繁体   中英

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

i've written a console application deploy.exe which runs a batch script.

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. \shared1\lists\list1.cmd

If i run the executable byitself it runs successfully.

However i needed it to run in a windows installer project. So i made a setup and deployment project and added the deploy.exe successfully as custom action upon install.

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". 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. 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. It may not be where installer.bat is when you are installing it.

Also, you tried adding the bat file to a custom action (if that is even possible)?

And, would it possible to move what is in the bat to the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM