Avatar of oconnork00
oconnork00Flag for United States of America asked on

Executing a batch file from a web page

Hi all,

I run Win 2008 R2 on my VPS.
Occasionally I need to run a batch file. To do this I would log into the VPS and run the batch on the desktop.

However, I was wondering for an easier solution if I could do this:

On a web page that's served from the win 2008 R2 IIS machine, have a pag with a button on it, that when I click it runs the batch file on my VPS desktop?

This would save me a lot of time and I can do this as and when I need to on my smart phone.

Thanks in advance for your help.
Microsoft IIS Web Server

Avatar of undefined
Last Comment
oconnork00

8/22/2022 - Mon
Emmanuel Adebayo

Hi,

Does this has to be run at random or do you have time to run this specifically? have you thought of set it up as a schedule?

You can set this as a page on your website and run from there whenever you will.

Do you know how to go about in this in IIS?

Regards
Sumesh BNR

I don't think it is possible but somebody may help you.  

Try an another method method: use task scheduler to run this batch file

Set a scheduled task for running a batch file The batch file location can be specified in the FTP path of your desktop .(you need to setup FTP server if you don't have)

Use any FTP client and upload the file whenever you want to run .

But how you schedule the time or frequency of the scheduled task ? doubting?

make a vbscript instead of the batch file and schedule another task and say in your vbscipt to run when a batch file is available in you FTP folder.Get it ? or try any monitor and execute tools with command line option to run the batch file

or try psexec tool http://babyraj.com/add-a-network-share-to-a-users-pc-remotely-on-windows/
ASKER
oconnork00

I currently use task scheduler for other tools I made. However I would much rather prefer a web based startup, if it was possible.

Thanks for the reply though.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Emmanuel Adebayo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Johnson, CD

Depends upon where you want the file to run and with what permissions?

locally (download or open the batch file from the webpage)
on the vps server, all you need is a button_click event, and in the code behind you call the batch file and it will run in the context of the current app pool identity. This 'user' must have execute permissions on that file.
ASKER
oconnork00

I've no problem calling the batch file from anywhere on the VPS, but if it's easier I can run it from within the IIS folder where the initial webpage doing the "calling" would be placed.

Can you point me to some sample code for the solution you're suggesting?

Thanks
ASKER
oconnork00

Depends upon where you want the file to run and with what permissions?

locally (download or open the batch file from the webpage)
on the vps server, all you need is a button_click event, and in the code behind you call the batch file and it will run in the context of the current app pool identity. This 'user' must have execute permissions on that file.

So I'd need to be logged into the VPS to do this then would I?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
oconnork00

What about triggering a VBS script? Can that be done? Still stuck on this problem.