Spawning asynchronous server-side scripts

M

MikeT

I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)

This starts the script OK, and will log what it is doing to a logfile
on the server so I can see what is going on. What I cannot do is
access a UNC share.

From what I can see, if my intranet runs as a pooled thread or as its
own thread, the script gets executed in the user context of the
IWAM_machine account. If I set the intranet to run as part of IIS, it
gets executed under the SYSTEM account. Neither of these have access
to shares in the larger domain, for obvious reasons.

So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

I can't really map lots of network drives as there are more potential
share locations than letters in the alphabet and the locations
regularly change. I can't map temporary network drives as multiple
copies of the script may be executing at once. So that's using the
wshNetwork object out the window :(

I really don't want to have to compile an .exe to do this as keeping
everything as script files makes it much easier to maintain and
update.
 
T

Tom Kaminski [MVP]

MikeT said:
I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)

This starts the script OK, and will log what it is doing to a logfile
on the server so I can see what is going on. What I cannot do is
access a UNC share.

From what I can see, if my intranet runs as a pooled thread or as its
own thread, the script gets executed in the user context of the
IWAM_machine account. If I set the intranet to run as part of IIS, it
gets executed under the SYSTEM account. Neither of these have access
to shares in the larger domain, for obvious reasons.

So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

Make your script a script component, register it in COM+, and set it to run
with an appropriate identity so it can access the network.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/lettitle.asp
 
M

MikeT

Tom Kaminski said:
MikeT said:
I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)
[snip]
So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

Make your script a script component, register it in COM+, and set it to run
with an appropriate identity so it can access the network.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/lettitle.asp

Thanks for that - not many changes are needed to make this a .wsc
component. Forgive me for being stupid, but how do I call this
component/write this component so that it runs the file transfer and
renaming asynchronously from the host .asp script?
 
T

Tom Kaminski [MVP]

MikeT said:
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
MikeT said:
I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)
[snip]
So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

Make your script a script component, register it in COM+, and set it to run
with an appropriate identity so it can access the network.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/lettitle.asp

Thanks for that - not many changes are needed to make this a .wsc
component. Forgive me for being stupid, but how do I call this
component/write this component so that it runs the file transfer and
renaming asynchronously from the host .asp script?

Sorry, I missed the asynchronous bit. This might help:
http://www.aspfree.com/articles/644,1/articles.aspx
 
T

Tom Kaminski [MVP]

Tom Kaminski said:
MikeT said:
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)
[snip]
So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

Make your script a script component, register it in COM+, and set it
to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/lettitle.asp
Thanks for that - not many changes are needed to make this a .wsc
component. Forgive me for being stupid, but how do I call this
component/write this component so that it runs the file transfer and
renaming asynchronously from the host .asp script?

Sorry, I missed the asynchronous bit. This might help:
http://www.aspfree.com/articles/644,1/articles.aspx

Here's another thought - how about using wshShell.Run to call "Soon" (or
"AT" if you don't have the ResKit), which can "schedule" your script to run
in a few seconds?
 
M

MikeT

Tom Kaminski said:
Tom Kaminski said:
MikeT said:
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
I need to start a lengthy file copy process going on our intranet
server from a .asp page. Since the .asp cannot wait for this to
complete - it might take anything up to half an hour - I've been
trying to use wshShell.Run to start a .wsf script running on the
server itself:

ignore = wshShell.Run("%comspec% /c ""cscript " & scriptpath & " " &
arguments & """", 1, false)
[snip]
So, is there a better way to start a process going without having to
wait for it to finish under an account that _does_ have rights to
these shares?

Make your script a script component, register it in COM+, and set it
to
run
with an appropriate identity so it can access the network.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/lettitle.asp
Thanks for that - not many changes are needed to make this a .wsc
component. Forgive me for being stupid, but how do I call this
component/write this component so that it runs the file transfer and
renaming asynchronously from the host .asp script?

Sorry, I missed the asynchronous bit. This might help:
http://www.aspfree.com/articles/644,1/articles.aspx

Here's another thought - how about using wshShell.Run to call "Soon" (or
"AT" if you don't have the ResKit), which can "schedule" your script to run
in a few seconds?

I'll take a look at that too, but won't that just run the script in
the same user-contexts as I experienced with wshShell.Run above?

The aspfree link looks interesting - seems a much better fit to my
problem at first glance anyway. Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top