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.Sta rtupPath & "\Output.tx t"
'
' Get the System path.
'
Dim sysFolder As String =
System.Environm ent.GetFolderPa th(Environment. SpecialFolder.S ystem)
'
' Createe the command line.
'
myProcess.Start Info.FileName = "cmd.exe"
myProcess.Start Info.Arguments = "/C cd " & sysFolder & _
" && dir *.com >> " & Chr(34) & outfile & Chr(34) & " && exit"
'
' Start the process in a hidden window.
'
myProcess.Start Info.WindowStyl e = ProcessWindowSt yle.Hidden
myProcess.Start Info.CreateNoWi ndow = True
myProcess.Start ()
'
' Kill the process if it doesn't finish in one minute.
'
myProcess.WaitF orExit(1000)
If Not myProcess.HasEx ited Then
myProcess.Kill( )
End If
'
' Show the results.
'
MessageBox.Show ("The 'dir' command window was " & _
"closed at: " & myProcess.ExitT ime & "." &
System.Environm ent.NewLine & _
"Exit Code: " & myProcess.ExitC ode)
myProcess.Close ()
*************** *************
My Code
*************** *************** *************** *************** *************** ****
Dim myProcess As Process = New Process()
Dim s As String
Dim outfile As String = "\\cafe500\zebr a234"
'
' Get the System path.
'
Dim sysFolder As String =
System.Environm ent.GetFolderPa th(Environment. SpecialFolder.S ystem)
'
' Createe the command line.
'
myProcess.Start Info.FileName = "cmd.exe"
'myProcess.Star tInfo.Arguments = "/C cd " & sysFolder & " &&
dir *.com >> " & Chr(34) & outfile & Chr(34) & " && exit"
myProcess.Start Info.Arguments = "/C type C:\\239301U2.KA R >
\\xyz\zebra234"
'
' Start the process in a hidden window.
'
myProcess.Start Info.WindowStyl e = ProcessWindowSt yle.Hidden
myProcess.Start Info.CreateNoWi ndow = True
myProcess.Start ()
'
' Kill the process if it doesn't finish in one minute.
'
myProcess.WaitF orExit(1000)
If Not myProcess.HasEx ited Then
myProcess.Kill( )
End If
'
' Show the results.
'
Response.Write( "The 'dir' command window was " & _
"closed at: " & myProcess.ExitT ime & "." &
System.Environm ent.NewLine & _
"Exit Code: " & myProcess.ExitC ode)
myProcess.Close ()
*************** *************** *************** *************** *************** ****
I donno why it fails ..any help would be highly appreciated.
Kartik
"Jeff Dillon" <je**@removeeme rgencyreporting .com> wrote in message news:<uO******* *******@TK2MSFT NGP10.phx.gbl>. ..
Yes, a permissions issue most likely
Jeff
"kartik" <ka****@discuss ions.microsoft. com> wrote in message
news:EB******** *************** ***********@mic rosoft.com... No am not getting any error..In fact
this is the code
Dim aa As Integer
aa = Shell("C:\XYZ\A BC.bat", AppWinStyle.Max imizedFocus)
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.K AR > \\mynetworkmach ine\zebra234
where \\mynetworkmach ine\zebra234 has been provided network share..
I mean ...this works
type C:\abc\myfile.K AR > \\mynetworkmach ine\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****@discuss ions.microsoft. com> wrote in message
news:A0******** *************** ***********@mic rosoft.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_cmdshel l ""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