Members
Technology Zones
IBM Learning Center
Articles
Hosted By
Info
|
wscript.shell not working in asp..help
Last post 07-11-2008 11:00 AM by Veritant. 19 replies.
-
08-26-2005 1:14 PM
|
|
Advertisement
|
|
-
-
Veritant


- Joined on 11-02-2001
- United Kingdom

- Points 1,975
|
I think it might be a permission problem. Try this code to report any error:
Code:
<%
Dim wshell
set wshell = server.createobject("wscript.shell")
Response.Write("Starts here<br/>")
on error resume next
%>
<pre>
<%=now()%>
</pre>
<%
wshell.Run "notepad.exe c:\temp\textfile.txt", 1, false
Response.write "Passed through<br/>"
if err.number <> 0 then
response.write "Error detected: " & err.number & ": " & err.Description & "<br/>"
on error goto 0
response.end
end if
on error goto 0
Response.write "Run sucessfully<br/>"
%>
<pre>
<%=now()%>
</pre>
Veritant (John)
|
|
-
-
webjose


- Joined on 01-02-2002

- Points 11,015
|
Why do you need this?
It is awful strange to me that you want the server to open Notepad. Is there anyone logged into the server actually requiring that Notepad opens based on a client visiting certaing webpage? It doesn't make much sense to me.
Or maybe you are trying to show notepad in the client's computer? If you are trying to do that, then you have the code in the wrong side: You need a VBScript that runs in the CLIENT side.
Code:<script language="VBScript">
<!--
Dim oScript = CreateObject("WScript.Shell")
oScript.Run "notepad.exe " & strFilename, 1, True
-->
</script>
|
|
-
-
-
-
-
Sudeep Roy


- Joined on 07-06-2005

- Points 240
|
Not sure then...
Hi Veritant,
Thanks for the code you gave and it worked fine without any error.
Then I tried to run the exe which I actually want to run from my ASP page. I made the exe in Visual Basic, the code for which is as follows:
Sub Main()
Set oIELinkGeneral = CreateObject("InternetExplorer.Application")
Call oIELinkGeneral.Navigate("http://www.linkgeneral.com/logon.asp")
oIELinkGeneral.Visible = False
While oIELinkGeneral.ReadyState <> 4 Or oIELinkGeneral.Busy
Wend
oIELinkGeneral.document.Forms(1).Logon.Value = "seema"
oIELinkGeneral.document.Forms(1).password.Value = "12345"
oIELinkGeneral.document.Forms(1).LogonBtn.Click
While oIELinkGeneral.ReadyState <> 4 Or oIELinkGeneral.Busy
Wend
Call oIELinkGeneral.Navigate("http://www.linkgeneral.com/author.asp?addarticle=yes")
While oIELinkGeneral.ReadyState <> 4 Or oIELinkGeneral.Busy
Wend
oIELinkGeneral.document.Forms(1).subject.Value = "demo"
oIELinkGeneral.document.Forms(1).shortdescription.Value = "demoDescription"
oIELinkGeneral.document.Forms(1).catid.Value = "791"
oIELinkGeneral.document.Forms(1).articletext.Value = "demo article"
oIELinkGeneral.document.Forms(1).submitarticle.Click
While oIELinkGeneral.ReadyState <> 4 Or oIELinkGeneral.Busy
Wend
Call oIELinkGeneral.Navigate("http://www.linkgeneral.com/logon.asp?logout=yes")
While oIELinkGeneral.ReadyState <> 4 Or oIELinkGeneral.Busy
Wend
End Sub
I have written this code in a Module and in that VB Project there is only one module, no forms nothing. I made an exe of the project and saved it on the C: of the server.
Then in the code you provided i changed the line:
wshell.Run "notepad.exe c:\temp\textfile.txt", 1, false
to:
wshell.Run "c:\Project1.exe", 1, false
When I call the asp page it runs fine without any error. But, as you can see in the above code, I am trying to submit an article in that site, and when I go to that site I dont see any article submitted.
One more thing that I noticed is, when I checked the Task Manager on the server, I can see the exe still running under the Processess tab.
Can you please tell me what I should do to make it work?
Thanks once again.
PS: I got the following messages when I called the exe from ASP page
Starts here
8/31/2005 10:28:08 AM
Passed through
Run sucessfully
8/31/2005 10:28:08 AM
|
|
-
-
Thilak


- Joined on 02-22-2007

- Points 10
|
still having the same problem
I too getting the same problem..
When I try to run the following asp codes, it runs fine without any error. But nothing as coming in the screen.. I checked the Task Manager on the server, I can see the exe still running under the Processess tab.
Please tell me the solution for this
set SO = Server.CreateObject("WScript.SHELL")
so.Run "C:\CinergicSystem\Applications\Compiled\Scanner.exe", 1, FALSE
so.Run "%SystemRoot%\System32\calc.exe", 1, FALSE
Response.write "Passed through"
if err.number <> 0 then
response.write "Error detected: " & err.number & ": " & err.Description & ""
on error goto 0
response.end
end if
on error goto 0
Response.write "Run sucessfully"
set so = nothing
Cheers
thilak
|
|
-
-
Thilak


- Joined on 02-22-2007

- Points 10
|
Re: still having the same problem
another query:
how to call a VB DLL program from ASP. That VB dll program should call an .EXE program/file.
|
|
-
-
mingoclaros


- Joined on 03-25-2007
- Peru

- Points 5
|
Error detected: 70: Permiso denegado
What I Do??
|
|
-
-
jonpfl


- Joined on 07-09-2008
- United States

- Points 60
|
Veritant:I think it might be a permission problem. Try this code to report any error:
Code:
<% Dim wshell set wshell = server.createobject("wscript.shell") Response.Write("Starts here<br/>")
on error resume next
%> <pre> <%=now()%>
</pre> <%
wshell.Run "notepad.exe c:\temp\textfile.txt", 1, false
Response.write "Passed through<br/>"
if err.number <> 0 then response.write "Error detected: " & err.number & ": " & err.Description & "<br/>" on error goto 0 response.end end if on error goto 0 Response.write "Run sucessfully<br/>" %>
<pre> <%=now()%>
</pre>
I tried adding that to my code and it never returned. I assume I must have a permission problem but I do not know how to solve it?
Any ideas?
Thx
jonpfl
PS How do I turn off double spacing???
|
|
-
-
Veritant


- Joined on 11-02-2001
- United Kingdom

- Points 1,975
|
Hi Jon I am not sure of the problem here. You may be right that there is a permission problem, but I would expect that to be reported. You say you tried adding this to your code, but what is the rest of the code? Could there be some problem elsewhere? Did you try running the code I posted in a separate page, just to check that the basic mechanism works? You could add response.flush to push the output to the page to see how far it gets, that might help to narrow down the area in which the problem is. Good Luck!
If you use <shift><return> at the end of each line that will give you single spacing.
Veritant (John)
|
|
-
-
jonpfl


- Joined on 07-09-2008
- United States

- Points 60
|
Here are my two pages and it is still hanging : jon.asp <%@ Language=VBScript %> <% Option Explicit %>
<%
Dim WSHShell, WshEnv
Set WSHShell = CreateObject("WScript.Shell")Set WSHEnv = WSHShell.Environment("Process") WSHEnv("SEE_MASK_NOZONECHECKS") = 1
Response.Write( "Starts here<br/>") on error resume next
%> <pre>
<% =now()%> </pre>
<%
WSHShell.Run server.MapPath( "\credit_reporting\maintenance\business_subjects\jon_test.vbs"), 1, trueWSHEnv.Remove("SEE_MASK_NOZONECHECKS")
Response.write "Passed through<br/>" if err.number <> 0 then
response.write "Error detected: " & err.number & ": " & err.Description & "<br/>" on error goto 0
response.end
end if on error goto 0 Response.write "Run sucessfully<br/>"
%> <pre>
<% =now()%>
</ pre>
< html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jon</title></head> <body onload="">
< table width="100%"><tr><td>test</td></tr>
</ table></body> </html>
Here is the vbs file :
dim Mail
set Mail = CreateObject("CDO.Message")
'fill email fields
Mail.From= "xxx@xxx.com"
Mail.To= "xxx@xxx.com"
Mail.Subject= "test"
Mail.HTMLBody = "test"
Mail.Send 'email this messageset Mail = Nothing
|
|
-
-
jonpfl


- Joined on 07-09-2008
- United States

- Points 60
|
Veritant:
Hi Jon I am not sure of the problem here. You may be right that there is a permission problem, but I would expect that to be reported. You say you tried adding this to your code, but what is the rest of the code? Could there be some problem elsewhere? Did you try running the code I posted in a separate page, just to check that the basic mechanism works? You could add response.flush to push the output to the page to see how far it gets, that might help to narrow down the area in which the problem is. Good Luck!
If you use <shift><return> at the end of each line that will give you single spacing.
If you give me some code that you know works for you, I can try it on my end and see what happens. Maybe that is a better idea.
Thx jonpfl
|
|
-
-
jonpfl


- Joined on 07-09-2008
- United States

- Points 60
|
I tried doing this
sTemp = "cscript " & server.MapPath("\credit_reporting\maintenance\business_subjects\jon_test.vbs")
'WSHShell.Run server.MapPath("\credit_reporting\maintenance\business_subjects\jon_test.vbs"), 1, true
WSHShell.Run sTemp
And get this : Starts here
7/9/2008 2:49:26 PM
Passed through Error detected: 70: Permission denied
Thoughts? jonpfl
|
|
|
Search
Code Samples
New Members
|