473,225 Members | 1,592 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Create a Shell Object in ASP

Hej,
I want to run batchfiles via the Shell, but accessible in the Browser
via IIS. Actually, I'd like the server to start a command line ntbackup
if a users selects to do so on an ASP in his webbrowser. Does anyone
know how to create a shell object in an ASP?

Thanks,

Oliver
Jul 19 '05 #1
7 2654
You need elevated permissions: Set Shell = CreateObject("WScript.Shell")

A better plan is to store the commands in a table or text file, and have a
batch file wake up on a schedule (say every minute) and run all the tasks in
the table or file. Then you don't have to worry about making your anonymous
web user an administrator of the box... just a thought.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Oliver Gräser" <ep*************@gmx.de> wrote in message
news:cc*************@news.t-online.com...
Hej,
I want to run batchfiles via the Shell, but accessible in the Browser
via IIS. Actually, I'd like the server to start a command line ntbackup
if a users selects to do so on an ASP in his webbrowser. Does anyone
know how to create a shell object in an ASP?

Thanks,

Oliver

Jul 19 '05 #2
Oliver Gräser wrote:
Hej,
I want to run batchfiles via the Shell, but accessible in the Browser
via IIS. Actually, I'd like the server to start a command line
ntbackup if a users selects to do so on an ASP in his webbrowser.
Does anyone know how to create a shell object in an ASP?

Thanks,

Oliver

It can't be done. You can't initiate client-side programs from server-side
ASP script.

You will need to create an HTA, HTML Application, which is off-topic in this
newsgroup. Use Google to find information about it. Go to
msdn.microsoft.com/library to read about it. Client-side scripting groups
such as those with dhtml in their names, as well as the .scripting groups,
are the places to follow-up this question.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3
Sorry, don't understand the elevated permissions part. As far as I got
it, I cannot create WScript Objects running the IIS because it is a
different Scripting Host. Anyway, if I have this line

<%
Set objShell = WScript.CreateObject("Wscript.Shell")
Set objExecObject = objShell.Exec("cmd /c ntbackup backup _
""@C:\total.bks"" /J ""Alles"" /F ""X:\total.bkf"" /L:s ")
%>
in an ASP at a place where it is run, nothing happens.
For the workaround: Yep, I already have some scripts in the scheduler.
But for somem occasions we need extra backups, and some prerequisites
(stopping sql server, connecting to NAS etc) done. And I thought it
would come in handy if we could just do so by opening the web browser,
clicking some buttons and voila. Because otherwise, people tend to
forget something (like mounting the correct drive etc) and then backup
fails. It is only a tiny network without access from outside, so there
shouldn't be any harm.
Regards,

Oliver

Aaron [SQL Server MVP] schrieb:
You need elevated permissions: Set Shell = CreateObject("WScript.Shell")

A better plan is to store the commands in a table or text file, and have a
batch file wake up on a schedule (say every minute) and run all the tasks in
the table or file. Then you don't have to worry about making your anonymous
web user an administrator of the box... just a thought.

Jul 19 '05 #4
> Sorry, don't understand the elevated permissions part.

IIS runs using an anonymous account, IUSR_MachineName. This user, by
default, will not be able to run commands like ntbackup.
For the workaround: Yep, I already have some scripts in the scheduler.
I think you misunderstood what I meant.
But for somem occasions we need extra backups, and some prerequisites
(stopping sql server, connecting to NAS etc) done. And I thought it
would come in handy if we could just do so by opening the web browser,
clicking some buttons and voila.
What I am saying is that if the user wants to add an extra backup to the
schedule, he hits an ASP page, and the ASP page, rather than actually
performing the backup, stuffs the details of the task into a table, say.
Then, you have a different task (not a backup task!) in the scheduler, that
checks this tasks table every minute (or every hour, whatever), and if it
finds anything new, it runs it...
Because otherwise, people tend to
forget something (like mounting the correct drive etc) and then backup
fails.


Whatever task is responsible for the backup can notify appropriate people
when it fails. Do you really expect a user to sit on a web page, waiting
for a backup to complete? Do you know how HTTP works, and why this is not a
reasonable requirement?

If you want something more direct than this, look into a client-server
application, not a web page.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #5
Aaron [SQL Server MVP] schrieb:
Sorry, don't understand the elevated permissions part.

IIS runs using an anonymous account, IUSR_MachineName. This user, by
default, will not be able to run commands like ntbackup.


So if I would switch that to a Backup-Operator account it would be
possible?
For the workaround: Yep, I already have some scripts in the scheduler.

I think you misunderstood what I meant.


Might well be so;-) Actually I'm not really a computer guy.

But for somem occasions we need extra backups, and some prerequisites
(stopping sql server, connecting to NAS etc) done. And I thought it
would come in handy if we could just do so by opening the web browser,
clicking some buttons and voila.

What I am saying is that if the user wants to add an extra backup to the
schedule, he hits an ASP page, and the ASP page, rather than actually
performing the backup, stuffs the details of the task into a table, say.
Then, you have a different task (not a backup task!) in the scheduler, that
checks this tasks table every minute (or every hour, whatever), and if it
finds anything new, it runs it...


Sounds interesting. But I don't get the different task - not a backup
task thing. Can you give me a hint how to stuff tasks into the scheduler
or where to find more information about this? Thanks,..

Because otherwise, people tend to
forget something (like mounting the correct drive etc) and then backup
fails.

Whatever task is responsible for the backup can notify appropriate people
when it fails. Do you really expect a user to sit on a web page, waiting
for a backup to complete? Do you know how HTTP works, and why this is not a
reasonable requirement?


No, a little bit, no. Actually I'm a physikcs student and don't have
more IT knowledge than I need to run my simulations. I just do this
stuff for a small company because there is noone else. But if you can
give me hint how to get informed aboput tasks,maybe you're right that
this way is more suitable.

If you want something more direct than this, look into a client-server
application, not a web page.

surely not...
Jul 19 '05 #6
> So if I would switch that to a Backup-Operator account it would be
possible?
Maybe. But that's kind of like giving the dog the car keys because he needs
dog food.
But I don't get the different task - not a backup
task thing.
You said you have backups and other tasks in the scheduler already, that's
all.
Can you give me a hint how to stuff tasks into the scheduler
or where to find more information about this? Thanks,..


Do you have access to a database? Here is how I would do it for SQL Server:

CREATE TABLE tasks
(
taskID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
command VARCHAR(255) NOT NULL,
entered SMALLDATETIME NOT NULL DEFAULT GETDATE(),
started SMALLDATETIME,
completed SMALLDATETIME
)

Now, when someone goes to your web page and says, "I want to backup
C:\total.bks to X:\total.bkf" they select it from the list, or type it in,
or whatever (I don't know how you limit users to certain things like
stopping SQL Server, connecting to NAS, etc but prevent them from running
format c:\ /y), you insert the following:

Now, you have a VB executable, or a VBS script, or a C# command-line app, or
whatever, that polls this table for new tasks. The code might look
something like this:

set conn = CreateObject("ADODB.Connection")
conn.open "<connection string>"
set rs = conn.execute("SELECT taskID, command FROM Tasks WHERE started IS
NULL AND completed IS NULL")
if not rs.eof then
' hey hey, we have some work to do
set wshell = CreateObject("WScript.Shell")
do while not rs.eof
taskID = rs(0): command = rs(1)
conn.execute "UPDATE tasks SET started = GETDATE() WHERE taskID = "
& taskID
wshell.run command
conn.execute "UPDATE tasks SET completed = GETDATE() WHERE taskID =
" & taskID
rs.movenext
loop
end if
' of course, might want error handling, might need to replace " in command,
etc.
' but hopefully you get the drift...

So, let's say you called it PickUpWebTasks.vbs, and put it in c:\. Now, add
a scheduled task that runs PickUpWebTasks.vbs to the scheduler, and schedule
it to run every minute, or every hour, or whatever.

I can't really do much more for you without writing the actual application
for you. And I don't do that kind of work for free, sorry.

A
Jul 19 '05 #7
> stopping SQL Server, connecting to NAS, etc but prevent them from running
format c:\ /y), you insert the following:


Sorry, forgot the SQL statement.

conn.execute "INSERT Tasks(command) VALUES('" &
whatever_they_selected/entered & "')"

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Eskimo Joe | last post by:
I am trying to create a desktop icon using VB6. is this possible? -p
3
by: Nico | last post by:
I try to execute a shell command from ASP with: response.write("start") Set wshShell = CreateObject("WScript.Shell") wshShell.Run "notepad" Set wshShell = Nothing response.write("finished") ...
22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
11
by: Paul D.Smith | last post by:
Can Python create a variable "on-the-fly". For example I would like something like... make_variable('OSCAR', 'the grouch'); print OSCAR; ....to output... the grouch
1
by: G$ | last post by:
I'm trying to write some C# code to call the Windows Scripting Host (WSH) to create shortcuts, but I'm having problems. First, I referenced Windows Script Host Object Model. Then, I wrote the...
0
by: Vladimir Nesterovsky | last post by:
Hello, I'm having a trouble with a Shell.Folder object when I'm trying to use it from a C++ application, but at the same time, the same object works fine from within html script. The effect...
2
by: Mike John | last post by:
I am trying to use the shell object to send keys to the explorer browser to run the send page funcion. I am receiving the above error only when I put my html file in the web server...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
0
by: Dale | last post by:
Access 2000 I have a check scanner from Magtek, (MicrImage) This is like a "point of sale" check scanner/credit card reader. Magtek furnished 2 ocx's (MTMicrImage.ocx & SaxComm8.ocx). They also...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.