running a batch file

Discussion in 'ASP General' started by Doug at SAU, Jun 20, 2005.

  1. Doug at SAU

    Doug at SAU Guest

    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.
     
    Doug at SAU, Jun 20, 2005
    #1
    1. Advertising

  2. Doug at SAU

    Evertjan. Guest

    =?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)
     
    Evertjan., Jun 20, 2005
    #2
    1. Advertising

  3. Doug at SAU

    Doug @ SAU Guest

    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)
    >
    >
     
    Doug @ SAU, Jun 20, 2005
    #3
  4. Doug at SAU

    Evertjan. Guest

    =?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)
     
    Evertjan., Jun 20, 2005
    #4
  5. Doug at SAU

    Evertjan. Guest

    Chris Hohmann wrote on 21 jun 2005 in
    microsoft.public.inetserver.asp.general:

    > "Doug at SAU" <Doug at > wrote in message
    > news:...
    >>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!


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Jun 20, 2005
    #5
  6. Chris Hohmann, Jun 20, 2005
    #6
  7. "Evertjan." <> 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 > wrote in message
    >> news:...
    >>>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
     
    Chris Hohmann, Jun 21, 2005
    #7
  8. Doug at SAU

    JitGanguly Guest

    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." <> 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 > wrote in message
    > >> news:...
    > >>>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
    >
    >
    >
    >
     
    JitGanguly, Jun 21, 2005
    #8
  9. Doug at SAU

    Doug @ SAU Guest

    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!!
     
    Doug @ SAU, Jun 21, 2005
    #9
  10. "Doug @ SAU" <> wrote in message
    news:...
    > 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
     
    Chris Hohmann, Jun 21, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Kraft

    running dos batch file

    John Kraft, Feb 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    639
    Brian W
    Feb 3, 2004
  2. John McGinty

    Running batch script from ASP.NET page

    John McGinty, Sep 28, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    778
    John McGinty
    Sep 28, 2004
  3. UJ
    Replies:
    2
    Views:
    14,558
    Acheliz
    Jun 23, 2008
  4. David Hubbard
    Replies:
    0
    Views:
    466
    David Hubbard
    Jan 24, 2006
  5. Bruce Horrocks
    Replies:
    3
    Views:
    279
    Bruce Horrocks
    Jan 1, 2004
Loading...

Share This Page