By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

running a batch file

P: n/a
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.


Jul 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
=?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)

Jul 22 '05 #2

P: n/a
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)

Jul 22 '05 #3

P: n/a
=?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)

Jul 22 '05 #4

P: n/a
"Doug at SAU" <Doug at SA*@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
I need to run a batch file on a remote machine from an ASP page.

[snip]

http://msdn.microsoft.com/library/en...refromhere.asp
Jul 22 '05 #5

P: n/a
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:
"Doug at SAU" <Doug at SA*@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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)

Jul 22 '05 #6

P: n/a
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.242...
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:
"Doug at SAU" <Doug at SA*@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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

Jul 22 '05 #7

P: n/a
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." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.242...
Chris Hohmann wrote on 21 jun 2005 in
microsoft.public.inetserver.asp.general:
"Doug at SAU" <Doug at SA*@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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

Jul 22 '05 #8

P: n/a

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!!
Jul 22 '05 #9

P: n/a
"Doug @ SAU" <Do*****@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
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
Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.