Click here to Skip to main content
15,844,477 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Is it possible to execute .bat through a WebAPI call?
I created a Windows Service. Then I created several .bat files to install, uninstall, start, or stop the service.
Now I want to use a WebAPI call to run a .bat file.

What I have tried:

Execute .bat through a WebAPI call?
Posted
Updated 12-Sep-23 9:24am
v4
Comments
PIEBALDconsult 11-Sep-23 10:05am    
One hopes not.
More detail is required.
Richard MacCutchan 11-Sep-23 10:10am    
Maybe, but what would it be used for?
Actually, there is a simple way to find the answer to such a question.
s yu 11-Sep-23 10:13am    
Please provide additional details. Thanks.
Richard MacCutchan 11-Sep-23 10:17am    
Details of what? I have no idea what you are trying to do.
s yu 11-Sep-23 10:19am    
What's your proposed "Simple Way"?

1 solution

Probably not: Your API code will be running on your server, not on your client - so any .BAT file will also execute on the server, not the client. And regardless of what the file does, the server has no way to access executables on the client computer for security reasons.

And if you want the BAT file to run on the server, execute it directly from your server code ... you don't need an API for that!
 
Share this answer
 
Comments
s yu 11-Sep-23 12:28pm    
Make sense. Thanks for your provided solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900