Actually no.I can execute file creations commands...more likely a
network issue.The following code from
http://www.thescarms.com/dotNet/Process.asp executes perfectly
fine.But when I execute my code it fails with exitcode = -1.
Sample Code from
http://www.thescarms.com/dotNet/Process.asp
*****************************
Dim myProcess As Process = New Process()
Dim s As String
Dim outfile As String = Application.StartupPath & "\Output.txt"
'
' Get the System path.
'
Dim sysFolder As String =
System.Environment.GetFolderPath(Environment.Speci alFolder.System)
'
' Createe the command line.
'
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.Arguments = "/C cd " & sysFolder & _
" && dir *.com >> " & Chr(34) & outfile & Chr(34) & " && exit"
'
' Start the process in a hidden window.
'
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
'
' Kill the process if it doesn't finish in one minute.
'
myProcess.WaitForExit(1000)
If Not myProcess.HasExited Then
myProcess.Kill()
End If
'
' Show the results.
'
MessageBox.Show("The 'dir' command window was " & _
"closed at: " & myProcess.ExitTime & "." &
System.Environment.NewLine & _
"Exit Code: " & myProcess.ExitCode)
myProcess.Close()
****************************
My Code
************************************************** *****************************
Dim myProcess As Process = New Process()
Dim s As String
Dim outfile As String = "\\cafe500\zebra234"
'
' Get the System path.
'
Dim sysFolder As String =
System.Environment.GetFolderPath(Environment.Speci alFolder.System)
'
' Createe the command line.
'
myProcess.StartInfo.FileName = "cmd.exe"
'myProcess.StartInfo.Arguments = "/C cd " & sysFolder & " &&
dir *.com >> " & Chr(34) & outfile & Chr(34) & " && exit"
myProcess.StartInfo.Arguments = "/C type C:\\239301U2.KAR >
\\xyz\zebra234"
'
' Start the process in a hidden window.
'
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
'
' Kill the process if it doesn't finish in one minute.
'
myProcess.WaitForExit(1000)
If Not myProcess.HasExited Then
myProcess.Kill()
End If
'
' Show the results.
'
Response.Write("The 'dir' command window was " & _
"closed at: " & myProcess.ExitTime & "." &
System.Environment.NewLine & _
"Exit Code: " & myProcess.ExitCode)
myProcess.Close()
************************************************** *****************************
I donno why it fails ..any help would be highly appreciated.
Kartik
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message news:<uO**************@TK2MSFTNGP10.phx.gbl>...
Yes, a permissions issue most likely
Jeff
"kartik" <ka****@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com... No am not getting any error..In fact
this is the code
Dim aa As Integer
aa = Shell("C:\XYZ\ABC.bat", AppWinStyle.MaximizedFocus)
and when i run in debug mode I get a value for aa..which is the process
id.
ABC.bat contains the following lines
type C:\abc\myfile.KAR > \\mynetworkmachine\zebra234
where \\mynetworkmachine\zebra234 has been provided network share..
I mean ...this works
type C:\abc\myfile.KAR > \\mynetworkmachine\zebra234
when i execute this through dos.
Thanks in Anticipation
Kartik
"Jeff Dillon" wrote:
I believe the xp_cmdshell is using the permissions of the user that the SQL Server itself runs under.
Also, are you getting an error??
Jeff
"Kartik" <Ka****@discussions.microsoft.com> wrote in message
news:A0**********************************@microsof t.com...
> Hi,
>
> I have an ASP.NET application using VB.NET.I am sending a DOS command to a > machine on the network to print a file.
> This is achieved using xp_cmdshell
>
>
> Dim str As String = "xp_cmdshell ""type " & nwkfilepath & " > " & > pPrinterName & " """
>
> and str is executed in the MSSQL Master database which has got permissions > to do it.
>
>
> Problem Statement
> ******************
> The same functionality could not be achieved using shell or diagnostics > namespace.The user ASP.NET has
> already been given admin rights(as this is the user that executes an aspx > page)
>
>
>
> Any help would be highly appreciated as this has snowballed into a major > production issue.
>
>
> Regards
>
> Kartik Ganesan