06-20-06 12:25 PM
Dim oShell
Set oShell = Server.CreateObject("WSCript.shell")
dScript = "wscript \\hank\scripts\test.vbs"
try = oShell.Run(dScript)
Response.Write try
"Bob" <newsome.bob@gmail.com> wrote in message
news:1150740156.189420.38730@p79g2000cwp.googlegroups.com...
>I have created some WSH scripts on my Webserver that are executed by
> the Windows Task Scheduler. I want to be able to execute some of these
> scripts using a web interface and don't want to duplicate these scripts
> in ASP. I know this can be done using the WScript.Shell run method but
> I am having no success. Below is a test application I have thrown
> together to demonstrate my problem.
>
> If I run c:\intetpub\wwwroot\wshasp\storetime.vbs from the server's
> command line it appends the text file
> c:\intetpub\wwwroot\wshasp\storetime.vbs with the current time. I can
> do this forever and it keeps adding the time to the file, no problem
> whatsoever. If I run the ASP using a browser I get nothing, no errors,
> just a browser page with "objWSH.run Result: 0", no time is appended to
> storedtime.txt, no errors are recorded in any logs.
>
> I have adjusted security settings for iusr_MACHINENAME to allow
> read/write/execute.
>
> Finally, I have successfully used the wscript.shell object in an ASP
> function to make a direct call to ping, dir, etc. and pipe the results
> to a text file.
>
> I have incorporated many things in the following code that I found
> searching this group and many links found on Google. Nothing seems to
> work, any ideas?
>
>
> EXAMPLE CODE FOLLOWS
>
> c:\intetpub\wwwroot\wshasp\default.asp:
> = = = = = = = = = = = = = = = = = = = = = = = =
> <% @ Language = "VBScript" %>
> <%
> option explicit
>
> function testScript()
> dim objWSH
> dim intReturn
>
> intReturn = 7 'initialized the value to insure it changed
> set objWSH = server.createObject("wscript.shell")
> intReturn = objWSH.run("c:\intetpub\wwwroot\wshasp\storetime.vbs")
> set objWSH = nothing
> response.write("objWSH.run Result: " & intReturn & "<br />")
> end function 'daily_scripts
> %>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
>
> <head>
>
> <title>Test WSH</title>
>
> </head>
>
> <body>
>
> <%
> testScript()
> %>
>
> </body>
>
> </html>
> = = = = = = = = = = = = = = = = = = = = = = = =
>
>
> c:\intetpub\wwwroot\wshasp\storetime.vbs:
> = = = = = = = = = = = = = = = = = = = = = = = =
> option explicit
> dim objFSO
> dim objTextFile
>
> set objFSO = createObject("scripting.fileSystemObject")
> set objTextFile =
> objFSO.openTextFile("c:\intetpub\wwwroot\wshasp\storedtime.txt", 8,
> true)
> objTextFile.writeLine(now())
> objTextFile.close
> set objTextFile = nothing
> set objFSO = nothing
> = = = = = = = = = = = = = = = = = = = = = = = =
>
[ Post a follow-up to this message ]
|