Hope if anyone of you can help to solve my problem :(
Recently had developed an application in Web Form using ASP.Net.
This application will actually send out a document in encrypted and signed (encrypt and signed by SecurSign) format to customer.
In order to encrypt and sign the document, we need to execute the SecurSign application in DOS command (SecurSign only can run in DOS command). So, I have a function to prepare all the DOS command in a .bat file.
I am using:
System.Diagnostics.Process.Start(sRootPath & "bat\" & sBatFile)
to start/execute the .bat file
This .bat file is working fine in Window 2000. But unfortunately, we had upgraded our OS to
Win2k3. This web application was failed. No matter what kind of method i used also cannot start/execute the .bat file. But if I convert this source code into VB.Net. and run this application in Task Scheduler then is working fine. Is anyone
of you got any idea what's wrong?
May be the file and folder where it is located don't have permissions for the user that ASP.NET is using. Try setting "Full Control" to "Everyone" just to test if it works, and then set then correct permisions for the user that ASP.NET is impersonating.
I had assigned everyone to have Full Control from the Root Directory until each files in the folder. But still not workable :(
I am not sure whether is IIS6.0 security issue or win2k3 issue. Is anyone of you have any idea?
Keep in mind that in order to execute a .bat file the account executing the file would also need access to cmd.exe. Permissions in IIS 6.0/Win2k3 are locked down by default so that you these commands can not be executed. It also depends on the account under
which the application pool runs. By default this is the Network Service account which is low priveleged that has no permissions to execute cmd.exe.
I have the same problem: I am running a web application in which I need to create a process to execute an external application. I have granted all the permisions to the ASPNET user, there is a thread running in system processes, but there is no window opened
(when it should be opened) and no action is performed by this thread (I have tried even calling a .bat file in vane).
If you know how to solve this matter, please tell me.
Thank you.
I too have this problem except that once upon a time it actually worked. The environment is XP development and 2003 production. The need was for a nslookup and a very simple portscan from the Intranet which is VB.Net. The easy solution was to create a
batch file (actually it was a .CMD) and then just suck the results back into the web page. This worked fine except I could never get the system.diagnostics.process version to work so had to resort to SHELL and looking to see when the script ended. Then
magically about a week ago (this has been working for over 8 months now) one of the users reported it does not work anymore. Investigation shows it does not work on development either. More debugging and it is not related to permissions (well mostly), I
did discover that I could do this - shell("cmd.exe /c dir > test.txt") and that works, but shell("cmd.exe /c mybatch.cmd") does not work and there is no error message either. Eventually after much f*&^ing around, I decided that something (a service
pack/hotfix ?) had changed 'something' but there was no way that a cmd or bat would work anymore. But I did find a way around the problem, although your batch files must be quite simple now, really just lines of things to run. So here is the way to trick
the whole thing into working - cat the batch file into cmd.exe Here is the code for the nslookup script (parts of it ripped out for brevity)
'create some temp filenames
Dim TSerial
As String = Trim(Str(Now.Ticks))
Dim fDone
As String = "c:\temprun\output" + TSerial + ".done"
Dim fOut
As String = "c:\temprun\output" + TSerial + ".txt"
Dim fCmd
As String = "c:\temprun\getns" + TSerial + ".ccd"
' ***** execute the batch file - this way used to work, but does not work any longer
' **** Shell(fcmd,AppWinStyle.NormalFocus)
' wait for it to complete (the ultra slack way)
Do While
Not System.IO.File.Exists(fDone)
Delay(1)
Loop
' now open the fOut and display the results on the web page and cleanup temp files etc etc etc
The last thing you have to do is a permission - cmd.exe normally resides in %systemroot%\system32 There is no way that the permissions on this allow execution by the IIS process. On development the user running cmd.exe is ASPNET - add this
to cmd.exe with execute. On production it is the account defined in the application pool, add that to cmd.exe with execute. I just cheated and added 'everyone' with execute to cmd.exe - after all this is an Intranet site not an external facing one so I
can be a little slap-hazard with the file permissions.
Oh - one last thing, you can't get a window to display, it always runs hidden, which makes sense as the process is running as a user who does not have access to the current console window. I guess if you logged in as ASPNET you might get a window to pop up
- never tried it though.
Good Luck - I hope this helps you with your batch files from IIS
We're trying to call an exe from a WCF service.
We have not been able to get the process to invoke the exe at all.
The WCF service tier is set up to use win authentication with no impersonation.
<security mode="TransportCredentialOnly"><transport clientCredentialType="Windows" /></security>The app pool
is running under the normal service account and we're using System.Disgonistics.Process to invoke the command:System.Diagnostics.Process proc =
new System.Diagnostics.Process();proc.EnableRaisingEvents =
false;proc.StartInfo.CreateNoWindow =
true;proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;proc.StartInfo.RedirectStandardOutput
= true;proc.StartInfo.UseShellExecute =
false;proc.StartInfo.FileName =
"C:\Appligent\SecurSign\secursignapp.exe";proc.StartInfo.Arguments =
"......";proc.Start();proc.WaitForExit();proc.Close();We've
given the folder C:\Appligent\SecurSign\ as much as "Everyone+full control" permission to no avail. It's really baffling as to what is going on here.Q1: would the
process invoked also run under Network Service?Q2: if so, what type of permission or policy setting is required to run proc.Start()?
When you you next go to enter source code, you will have an additional toolbar - the top rightmost button is for source entry.
Rather than grant additonal rights to the Web Site process, why not write a Windows Service to run the transformation. The sequence would be:
Web site writed a request to a queue table in a database accessible to both the web site and the web service.
Windows service polls the queue for work, runs the process, flags the record as done.
The web page ahas some AJAX to poll for process status, and when completion of the job is detected, it displays the hyperlink to download the file.
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
pikkim
Member
10 Points
2 Posts
Execute .bat file in Web Form using ASP.Net
Jul 26, 2005 11:02 AM|LINK
hi,
Hope if anyone of you can help to solve my problem :(
Recently had developed an application in Web Form using ASP.Net.
This application will actually send out a document in encrypted and signed (encrypt and signed by SecurSign) format to customer.
In order to encrypt and sign the document, we need to execute the SecurSign application in DOS command (SecurSign only can run in DOS command). So, I have a function to prepare all the DOS command in a .bat file.
I am using:
System.Diagnostics.Process.Start(sRootPath & "bat\" & sBatFile)
to start/execute the .bat file
This .bat file is working fine in Window 2000. But unfortunately, we had upgraded our OS to Win2k3. This web application was failed. No matter what kind of method i used also cannot start/execute the .bat file. But if I convert this source code into VB.Net. and run this application in Task Scheduler then is working fine. Is anyone of you got any idea what's wrong?
please help.....
LuKiller
Participant
789 Points
170 Posts
Re: Execute .bat file in Web Form using ASP.Net
Jul 26, 2005 01:06 PM|LINK
http://www.lukiller.net
pikkim
Member
10 Points
2 Posts
Re: Execute .bat file in Web Form using ASP.Net
Jul 27, 2005 03:49 AM|LINK
I had assigned everyone to have Full Control from the Root Directory until each files in the folder. But still not workable :(
I am not sure whether is IIS6.0 security issue or win2k3 issue. Is anyone of you have any idea?
please help...
klevereblog
Member
265 Points
53 Posts
Re: Execute .bat file in Web Form using ASP.Net
Sep 27, 2005 04:26 AM|LINK
Hosting Evangelist - CSNA (US)
Developer & Platform Evangelism Group
Blog: http://blogs.msdn.com/klevereblog
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subj
jldengra
Member
5 Points
1 Post
Re: Execute .bat file in Web Form using ASP.Net
Nov 03, 2005 07:06 PM|LINK
I have the same problem: I am running a web application in which I need to create a process to execute an external application. I have granted all the permisions to the ASPNET user, there is a thread running in system processes, but there is no window opened (when it should be opened) and no action is performed by this thread (I have tried even calling a .bat file in vane).
If you know how to solve this matter, please tell me.
Thank you.
drd0t
Member
5 Points
1 Post
Re: Execute .bat file in Web Form using ASP.Net
Nov 05, 2005 11:38 PM|LINK
Here is the code for the nslookup script (parts of it ripped out for brevity)
'create some temp filenamesThe last thing you have to do is a permission - cmd.exe normally resides in %systemroot%\system32 There is no way that the permissions on this allow execution by the IIS process. On development the user running cmd.exe is ASPNET - add this to cmd.exe with execute. On production it is the account defined in the application pool, add that to cmd.exe with execute. I just cheated and added 'everyone' with execute to cmd.exe - after all this is an Intranet site not an external facing one so I can be a little slap-hazard with the file permissions.
Oh - one last thing, you can't get a window to display, it always runs hidden, which makes sense as the process is running as a user who does not have access to the current console window. I guess if you logged in as ASPNET you might get a window to pop up - never tried it though.
Good Luck - I hope this helps you with your batch files from IIS
dyemane
Member
2 Points
5 Posts
Re: Execute .bat file in Web Form using ASP.Net
Jan 29, 2009 10:26 PM|LINK
Has anyone been able to resolve this?
We're trying to call an exe from a WCF service. We have not been able to get the process to invoke the exe at all. The WCF service tier is set up to use win authentication with no impersonation. <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /></security> The app pool is running under the normal service account and we're using System.Disgonistics.Process to invoke the command:System.Diagnostics.Process proc = new System.Diagnostics.Process();proc.EnableRaisingEvents = false;proc.StartInfo.CreateNoWindow = true;proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;proc.StartInfo.RedirectStandardOutput = true;proc.StartInfo.UseShellExecute = false;proc.StartInfo.FileName = "C:\Appligent\SecurSign\secursignapp.exe";proc.StartInfo.Arguments = "......";proc.Start();proc.WaitForExit();proc.Close(); We've given the folder C:\Appligent\SecurSign\ as much as "Everyone+full control" permission to no avail. It's really baffling as to what is going on here.Q1: would the process invoked also run under Network Service?Q2: if so, what type of permission or policy setting is required to run proc.Start()?TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Execute .bat file in Web Form using ASP.Net
Feb 05, 2009 02:42 PM|LINK
First a very general point, please:
Rather than grant additonal rights to the Web Site process, why not write a Windows Service to run the transformation. The sequence would be:
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239