SaqibBhatti-3239 avatar image
0 Votes"
SaqibBhatti-3239 asked PengGe-MSFT commented

How to run a ".bat" file during Install Custom Action

I am creating an installer using Visual Studio Setup. In the File System, I have created a folder named 'Batch' and put batch file there. Now on Install Custom Action properties, in the Source Path field I enter this

but in the Arguments filed I don't know what to enter. If I give Local disk path then it won't work on another PC.

Any help will be highly appreciated.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @SaqibBhatti-3239
I found something that might be useful to you:

1.Create a setup project and configure as you normally would, including the subdirectory in which you'll place your batch file (you can just place it in the Application Folder directly if you don't want it in a subdirectory).
2.In the "File System" view (right-click on the project in Solution Explorer->View->File System), add the batch file you want to execute and cmd.exe (C:\Windows\System32\cmd.exe)
3.Open the "Custom Actions" view (right-click on the project in Solution Explorer->View->Custom Actions)
4.Right-click on "Commit" and choose "Add Custom Action"
5.Navigate to and select cmd.exe.
6.Open the properties panel for the newly created custom action.
7.Delete /Commit from the Arguments property.
8.Enter: /c "[TARGETDIR]subdirectoryname\batchfile.bat" in the Arguments property, where subdirectoryname should be replaced by the name of your subdirectory (if you put the batch file in a subdirectory like I did... if you didn' t, the value should be /c "[TARGETDIR]batchfile.bat") and batchfile.bat should be the filename of your batch file.

You can refer to this thread.

By the way, the vs-setup tag is Technical questions about installation, uninstallation and upgrade of Visual Studio.

0 Votes 0 ·

/c "[TARGETDIR]subdirectoryname\batchfile.bat

What is [TARGETDIR] in the above line ? Can you please explain.


0 Votes 0 ·

According to the description in that thread, [TARGETDIR] is the directory containing a batch (.bat) file. I suggest you post your issue on Stackoverflow.

0 Votes 0 ·

0 Answers