473,424 Members | 1,817 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,424 software developers and data experts.

Process.Start() with username and password hangs

Hi,
I'm trying to kick off the iiscnfg.vbs from a webservice to export a
website's config to an xml file (And eventually populate other servers with
the config). I initially tried this using the 1.1 framework, but discovered
that when I used Process.Start() the user's credentials were not
impersonated, it just kept using the asp.net's user, so I switched the
webservice over to 2.0 as Diagnostics.Process.StartInfo now has username,
password and domain properties. If I set these however, the service hangs. If
I check the processes list on the server, I can see that cscript.exe fires
up, but nothing else seems to happen. If I kill that process then the
webservice returns but the script never gets run, otherwise it just sits
there, probably until my browser would timeout. If I take away the username
and password, the script runs fine, however it returns access denied due to
the ASP.NET account not having permission to run that script. Does anyone
have any idea why it's locking up, I tried just running a .bat file, but that
locked up too! So it's not cscript it's having problems with... here's the
VB.NET code I've written:

<WebMethod()> _
Public Function publishToCluster(ByVal site As String) As String
Try
Return copyIISTree("/lm/w3svc/" & site, "")
Catch ex As Exception
Return ex.ToString
End Try
End Function

Private Function copyIISTree(ByVal sourcePath As String, ByVal
destinationPath As String) As String

Dim p As New Diagnostics.Process
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.UseShellExecute = False
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
p.StartInfo.UserName = "<someusername>"
Dim pw As New System.Security.SecureString
For Each ch As Char In "<somepassword>"
pw.AppendChar(ch)
Next
p.StartInfo.Password = pw
p.StartInfo.Domain = "<somedomain>"
p.StartInfo.FileName = "c:\windows\system32\cscript.exe"
p.StartInfo.Arguments = "c:\windows\system32\iiscnfg.vbs /export /f
d:\test.xml /sp " & sourcePath & " /inherited /children"
p.Start()
Try
p.WaitForExit()
Catch ex As Exception
End Try
Dim output As String = ""
output = p.StandardOutput.ReadToEnd
p.Close()
p.Dispose()
Return output
End Function
Thanks.
--
Paul.
Jan 5 '06 #1
0 7178

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

Similar topics

5
by: toby | last post by:
Can any one help? I'm trying to use System.Diagnostics.Process.Start to open legacy MS access aplications (ade and mdb files) and vb 6 .exe's using asp.net. There is something confusing going on?!?...
1
by: Bucky Pollard | last post by:
I have a web service that needs to create a batch file and call it (since there are no APIs for the functionality I am looking for). I am using the Process and ProcessStartInfo objects. When I try...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
8
by: Philip Wagenaar | last post by:
I need to send printjobs to a printqueue under diffrent usernames. The printsoftware on the queue is not very 'secure' so I can create a user on 1 system and send a printjob under it's name to the...
11
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then the process starts as the specified user, but hangs in a suspended state. In fact, any...
0
by: Kirk | last post by:
The following C# web service works fine until you uncomment the lines setting UserName and Password. Then, Process.Start throws an Access is Denied Exception. This is with .NET 2.0, of course...
6
by: Alexander Widera | last post by:
hello, if i start a program (an exe-file) with Process.Start(...) I don't have the required permissions that the programm needs (i could start the programm but the program needs special rights)....
0
by: Phil Appel | last post by:
I am attempting to launch an executable from an ASP.NET site using the following code: ---------- ProcessStartInfo psi = new ProcessStartInfo(sforcePath); psi.UseShellExecute = false;...
5
by: Saya | last post by:
Hi Folks, I have now spend app. 3 days to get the below scenario to work, but can not get there! ..Net version = 2.0.50727 Windows version = Microsoft Windows = Windows Server 2003 Now I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.