running a batch file

D

Doug at SAU

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.
 
E

Evertjan.

=?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.
 
D

Doug @ SAU

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.
 
E

Evertjan.

=?Utf-8?B?RG91ZyBAIFNBVQ==?= wrote on 20 jun 2005 in
microsoft.public.inetserver.asp.general:

[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]
 
C

Chris Hohmann

Evertjan. said:
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:
Doug at SAU said:
I need to run a batch file on a remote machine from an ASP page.
[snip]

http://msdn.microsoft.com/library/en-us/script56/html/wsconrunningscrip
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-us/script56/html/wstsksetupofremotewsh.asp
 
J

JitGanguly

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 said:
Evertjan. said:
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:
I need to run a batch file on a remote machine from an ASP page.
[snip]

http://msdn.microsoft.com/library/en-us/script56/html/wsconrunningscrip
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-us/script56/html/wstsksetupofremotewsh.asp
 
D

Doug @ SAU

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!!
 
C

Chris Hohmann

Doug @ SAU said:
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/prodtechnol/windowsserver2003/technologies/security/tkerbdel.mspx
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top