views:

7278

answers:

4

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?

A: 

Just guessing here, but maybe BaseDirectory doesn't have a trailing backslash. Try:

 System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "installer.bat");

instead.

Lucas Jones
nope that's not it. I see the script being run. I see the window coming on screen. It seems it's something to do with the installer.
Anirudh Goel
A: 

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?

Samuel
A: 

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.

Reed Copsey
Note the extra one in yours as well? Network paths are \\computer\rest
Samuel
Hehee, yeah. Oops.
Reed Copsey
A: 

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.

Anirudh Goel