Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > running a batch file

Reply
Thread Tools

running a batch file

 
 
Doug at SAU
Guest
Posts: n/a
 
      06-20-2005
I need to run a batch file on a remote machine from an ASP page. I dummied
up a test ASP page as follows:

<%
Set WshShell = Server.CreateObject("Wscript.Shell")
wshshell.run "c:\inetpub\wwwroot\logasp\getdr.bat > c:\tstlog.txt"
%>

the batch file is as follows:


set >c:\env.txt
dir c:\*.*


On my local machine, it runs fine, generating the env.txt and tstlog.txt
files. When I put it on another machine, the directory and environment
commands don't run. All I get is:


C:\WINDOWS\system32>set 1>c:\env.txt

C:\WINDOWS\system32>dir c:\*.*

for a response. I've tried setting the authentication to BASIC as suggested
by a Microsoft SME at TechED but to no avail. Why does it not work?

In the end, I need to be able to have the ASP page call a batch file to
change ACLS on files on a remote machine.

Any help would be appreciated.




 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      06-20-2005
=?Utf-8?B?RG91ZyBhdCBTQVU=?= wrote on 20 jun 2005 in
microsoft.public.inetserver.asp.general:

> I need to run a batch file on a remote machine from an ASP page. I
> dummied up a test ASP page as follows:
>
> <%
> Set WshShell = Server.CreateObject("Wscript.Shell")
> wshshell.run "c:\inetpub\wwwroot\logasp\getdr.bat > c:\tstlog.txt"
> %>
>


ASP runs on the server, not on a remote,
if you mean by remote the machine the browser runs on.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
 
 
 
Doug @ SAU
Guest
Posts: n/a
 
      06-20-2005
for clarification:

I am wanting to run a script from an asp page on a server against another
machine.

When I ran everything on my workstation, it worked fine. When I moved the
code to another machine and logged in, it didn't work.

The sample ASP page doesn't return anything, only a blank page. I have to
go to the server to see if the batch file ran on that machine.



"Evertjan." wrote:

> =?Utf-8?B?RG91ZyBhdCBTQVU=?= wrote on 20 jun 2005 in
> microsoft.public.inetserver.asp.general:
>
> > I need to run a batch file on a remote machine from an ASP page. I
> > dummied up a test ASP page as follows:
> >
> > <%
> > Set WshShell = Server.CreateObject("Wscript.Shell")
> > wshshell.run "c:\inetpub\wwwroot\logasp\getdr.bat > c:\tstlog.txt"
> > %>
> >

>
> ASP runs on the server, not on a remote,
> if you mean by remote the machine the browser runs on.
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>
>

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-20-2005
=?Utf-8?B?RG91ZyBAIFNBVQ==?= wrote on 20 jun 2005 in
microsoft.public.inetserver.asp.general:

> "Evertjan." wrote:
>
>> =?Utf-8?B?RG91ZyBhdCBTQVU=?= wrote on 20 jun 2005 in
>> microsoft.public.inetserver.asp.general:
>>
>> > I need to run a batch file on a remote machine from an ASP page. I
>> > dummied up a test ASP page as follows:
>> >
>> > <%
>> > Set WshShell = Server.CreateObject("Wscript.Shell")
>> > wshshell.run "c:\inetpub\wwwroot\logasp\getdr.bat > c:\tstlog.txt"
>> > %>
>> >

>>
>> ASP runs on the server, not on a remote,
>> if you mean by remote the machine the browser runs on.

>


[please do not toppost on usenet]

> for clarification:
>
> I am wanting to run a script from an asp page on a server against
> another machine.


So you want to run the asp file on a distant server and sun the shell
there?

> When I ran everything on my workstation, it worked fine. When I moved
> the code to another machine and logged in, it didn't work.
>
> The sample ASP page doesn't return anything, only a blank page. I
> have to go to the server to see if the batch file ran on that machine.


I think that must be a rights issue.

The process that runs ASP has very limited rights by default.

However if a blank file is made the batch must have run and you could
inspect the tstlog.txt file from remote by running another asp file with
Scripting.FileSystemObject. If you cannot reach c:\tstlog.txt because of
insufficient rights, the shell command would probably have the same
problem. [except for a possible read-only right]


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-20-2005
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:

> "Doug at SAU" <Doug at http://www.velocityreviews.com/forums/(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I need to run a batch file on a remote machine from an ASP page.

> [snip]
>
> http://msdn.microsoft.com/library/en...onrunningscrip
> tsremotelyrunningscriptovertherefromhere.asp


that is not from an ASP page!


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      06-20-2005
"Doug at SAU" <Doug at (E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to run a batch file on a remote machine from an ASP page.

[snip]

http://msdn.microsoft.com/library/en...refromhere.asp


 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      06-21-2005
"Evertjan." <(E-Mail Removed)> wrote in message
news:Xns967C37632895eejj99@194.109.133.242...
> Chris Hohmann wrote on 21 jun 2005 in
> microsoft.public.inetserver.asp.general:
>
>> "Doug at SAU" <Doug at (E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I need to run a batch file on a remote machine from an ASP page.

>> [snip]
>>
>> http://msdn.microsoft.com/library/en...onrunningscrip
>> tsremotelyrunningscriptovertherefromhere.asp

>
> that is not from an ASP page!


No need to shout. Doug already demonstrated a knowledge of being able to
reference WSH from ASP. As such, I gave him credit for being able to copy
and paste the following lines from the example into his ASP page:

set oController = CreateObject("WSHController")
set oProcess = oController.CreateScript("c:\wsh5.6\beenhere.wsf",
"remmachine")
oProcess.Execute

Note to Doug:
You'll need to enable remote scripting on the target server. Take note of
the link at the bottom of the article about "Setting Up Remote WSH":
http://msdn.microsoft.com/library/en...fremotewsh.asp



 
Reply With Quote
 
JitGanguly
Guest
Posts: n/a
 
      06-21-2005
Couple of things
1.Use UNC path.Theres nothing called mapped drive on network. SO if th
remote machine is abcdefg and drive is c then use
\\abcdefg\c$ ( assuming C$ is the share name)

2.When you run your ASP pages, it runs under IUSR_{yourservername} user.Make
sure thsi guy has permission on the remote server

"Chris Hohmann" wrote:

> "Evertjan." <(E-Mail Removed)> wrote in message
> news:Xns967C37632895eejj99@194.109.133.242...
> > Chris Hohmann wrote on 21 jun 2005 in
> > microsoft.public.inetserver.asp.general:
> >
> >> "Doug at SAU" <Doug at (E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >>>I need to run a batch file on a remote machine from an ASP page.
> >> [snip]
> >>
> >> http://msdn.microsoft.com/library/en...onrunningscrip
> >> tsremotelyrunningscriptovertherefromhere.asp

> >
> > that is not from an ASP page!

>
> No need to shout. Doug already demonstrated a knowledge of being able to
> reference WSH from ASP. As such, I gave him credit for being able to copy
> and paste the following lines from the example into his ASP page:
>
> set oController = CreateObject("WSHController")
> set oProcess = oController.CreateScript("c:\wsh5.6\beenhere.wsf",
> "remmachine")
> oProcess.Execute
>
> Note to Doug:
> You'll need to enable remote scripting on the target server. Take note of
> the link at the bottom of the article about "Setting Up Remote WSH":
> http://msdn.microsoft.com/library/en...fremotewsh.asp
>
>
>
>

 
Reply With Quote
 
Doug @ SAU
Guest
Posts: n/a
 
      06-21-2005

Thanks folks for the discussion. I really appreciate it.

What I found interesting was that during initial testing, although the batch
file DID run on the remote server, it returned no data, either the for the
environment or for the directory.

I will try the remote scripting settings that were suggested.

The concern is that it is running as IUSER_..... I had hoped that using
authentication, that it would take the credentials of the logged in user.

I'm toying with the idea of using integrated authentication to get access to
the ASP pages, then using a log in screen and capturing the login/password as
session variables, then having the code create the batch files to execute
commands in a RUNAS environment.

Feedback on this idea would be much appreciated.


THANKS AGAIN!!


 
Reply With Quote
 
Chris Hohmann
Guest
Posts: n/a
 
      06-21-2005
"Doug @ SAU" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The concern is that it is running as IUSER_..... I had hoped that using
> authentication, that it would take the credentials of the logged in user.


I believe this is the "double-hop" authentication issue. Basically, when
using challenge/response NTLM authentication the password never gets
transmitted, only a hash of it does. As such, the server is unable to act as
a delegate to access resources located on other machines. Here's a white
paper that does a much better job of describing the issue and also outlines
a number of methods for resolving it.

http://www.microsoft.com/technet/pro.../tkerbdel.mspx


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
schedule a task running a batch file iccsi Windows 64bit 0 03-27-2012 04:59 PM
Running a batch file from an ASP.Net page. UJ ASP .Net 2 06-23-2008 07:03 AM
running WebDev.WebServer from a batch file opens cmd window in background David Hubbard ASP .Net 0 01-24-2006 04:36 PM
running dos batch file John Kraft ASP .Net 1 02-03-2004 10:45 PM
Problem running multiple lwp-download commands from a Windows batch file Bruce Horrocks Perl Misc 3 01-01-2004 01:31 AM



Advertisments