Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

executing commandline program using ASP.NET

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Previusly i have used the windows scripting host to execute a program and then parse through the output of that program...

now under ASP.NET it seems that the wscript no longer exists at all!

I have tried using the shell() command and redirecting that to a text file so i can then read the output from the text file, but although the shell command exits with return value 0 (proscess complete), the text file i specified just doesnt exist

Can anyone tell me what namespace i can use or how to create a wshexec object, or why the textfile im specifying is not created? Or any other way i can execute a server side program on the server from an ASP.NET page

The program i am trying to execute is
"c:\program files\perforce\p4.exe" files //depot/...

eg:

shell("""c:\program files\perforce\p4.exe"" files //depot/...", vbminimisedfocus, true)

i have also tried:
shell("""c:\program files\perforce\p4.exe"" files //depot/... >> c:\output.txt", vbminimisedfocus, true)

and also written a batch file to do the file output:
shell("""c:\program files\perforce\p4tofile.bat""", vbminimisedfocus, true)


they all have not worked!


any help much appreciated...
 
in case anyone wants to know, i ended up solving it using the system.diagnostics.process object

I also changed the usewr account called ASPNET from standard user to power user, incase that was causing it to not be able to run the file

heres basically what i did to get it working:

Dim proc As New Process()

proc.StartInfo.FileName = "c:\program files\perforce\p4.exe"
proc.StartInfo.Arguments = "files //depot/p4replicator/..."
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True

proc.Start()
proc.WaitForExit()

Dim s As String = proc.StandardOutput.ReadToEnd()

Label1.Text = s


If anyone wants more details, let me know.
 
Congradulations on your success.
I've the similer kind of problem. I've to execute a vb script file at the server using WScript.exe. It is a simple script which connects to the database and creates a table.
My code is
Dim p as System.diagnostics.Process()
p.start("WScript.exe","C:\Inetpub\
This creates an entry in the Task Manager's process tab, but does not executes the script. The Script is working fine in Win App. My ASPNet account has admin privileges.

Then I used your code, on the WaitForExit statement the Server is throwing an error "System.InvalidOperationException: No Process is assosiated with this object"
Any help will be appreciated,
Regards
Adasoft
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top