473,387 Members | 1,295 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

shell command in web service

I'm trying to use system.diagnostics.process to print a pdf from ASP.NET 2.0
webservice (using a network printer). It works fine in an executable, but
fails in asp.net. What happens is that the executable runs & Acrobat gets
launched with no exceptions thrown, but the process is running under the
ASPNET account & the printing never takes place. I found out that the ASPNET
account, by design, is prohibited from doing certain things, so I

(a) set impersonation to a user account with network admin rights
(b) set the process.startinfo.username, password, & domain properties to the
same user account
(c) set "processmodel username" to "system" and "password" to "Autogenerate"

I get the same result each time. acrobat launches under ASPNET and the
printing never happens. I even moved the code to a console app and invoked
that in the web service; again, no dice. Any ideas??

Here is the console app code:

Sub Main()
Dim myprocess As System.Diagnostics.Process = New
System.Diagnostics.Process
Try
myprocess.StartInfo.FileName = "C:\AssurantLetter.pdf"
myprocess.StartInfo.Verb = "Print"
myprocess.StartInfo.CreateNoWindow = True
myprocess.Start()
System.Console.WriteLine("success")
Catch ex As Exception
System.Console.WriteLine(ex.ToString)
End Try
End Sub

here is the web service code:

Public Function testprint() As String
Dim myprocess As System.Diagnostics.Process = New
System.Diagnostics.Process
Dim objPassword As New System.Security.SecureString
Try
objPassword.AppendChar("p")
objPassword.AppendChar("a")
objPassword.AppendChar("s")
objPassword.AppendChar("s")
objPassword.AppendChar("w")
objPassword.AppendChar("o")
objPassword.AppendChar("r")
objPassword.AppendChar("d")
myprocess.StartInfo.UseShellExecute = False
myprocess.StartInfo.Domain = "DOMAINNAME"
myprocess.StartInfo.UserName = "username"
myprocess.StartInfo.Password = objPassword
myprocess.StartInfo.CreateNoWindow = True

myprocess.Start("C:\Inetpub\wwwroot\PrintManager\H elperComponents\ConsoleApplication1.exe")
Return "success"
Catch ex As Exception
Return ex.ToString
End Try
End Function
May 23 '06 #1
0 1381

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
8
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely...
1
by: tuckkhai | last post by:
Hi, I am a newbie in this area. I would like to know whether is it possible to execute shell command in windows service. I had install a program in the server which i would like it to be executed...
8
by: Stephen Long | last post by:
I'm looking for information on how i can open a remote command shell <cmd.exe> on a remote pc and perform basic DOS/Shell commands .. TIA Steve
3
by: BROQ | last post by:
Hi, I am using a windows service to extract every hour a log from our mailserver in order to parse the logfile. To do this I used the folowing code: Shell("""C:\pscp"" -pw *******...
2
by: Glenn Venzke | last post by:
I'm trying to print an Adobe forms file (.fdf) using system.diagnostics.process in a windows service. The problem is, IE is the program that launches that file type & Verb = "Print" doesn't work in...
3
by: Rob R. Ainscough | last post by:
I have a Windows Service with a timer that use the .NET 2.0 Shell command. The Shell command returns a non-zero number but Task Manager shows the shelled exe running but there is NO visible...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: eerpini | last post by:
On Mon, 2008-11-17 at 01:56 -0800, James Kanze wrote: he was not referring to shell access using the system() call so that he could run shell commands. He was rather looking for a shell access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.