Solved

using runas to open .msc with visual basic .net 2.0

Posted on 2011-03-23
4
705 Views
Last Modified: 2012-05-11
I am trying to use runas in some visual basic .net 2.0 code to open Custom_console.msc as another user.  For some reason I can go to a command line, cd to the dir where this file is, and run it.  When I try to use runas from the command line I get an error telling me this is not a valid 32 bit application.  When I use the process.start method and give it a password and userid I also get the error that this is not a valid 32 bit application.  However, if I right click on Custom_console.msc and choose runas from the context menu it works.  How can I do this from the command line or get this to work with visual basic?
0
Comment
Question by:chadmanvb
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 500 total points
ID: 35198503
VBForums has a similar question.
If that doesn't solve your problem, could you then post the code you use?
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 35198510
Hi,

  Set ProcessInfo.Verb property to runas. That should work for you. For more details refer the link http://www.mztools.com/articles/2009/MZ2009007.aspx.
0
 

Author Comment

by:chadmanvb
ID: 35198696
Easwaran, that did not work.  Below is the code I am using.  The code works fine if I have it point to an accual .exe application.  Djjar, im looking at your post now.
 Dim proConsoleStart As New Process

        With proConsoleStart.StartInfo
            .CreateNoWindow = True
            .UseShellExecute = False
            .WorkingDirectory = "c:\temp\Easy"
            .FileName = "cmd.exe"
            .Arguments = "/c runas /u:domain\" & strusername & " Custom_console.msc | sanur.exe " & strPPAccountPassword
            .Verb = "runas"

        End With
                proConsoleStart.Start()
0
 

Author Closing Comment

by:chadmanvb
ID: 35198818
Worked great!  

  Dim startupParm As String = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "C:\Temp\Easy\Custom_console.msc")
        Dim strPassword As String = strPPAccountPassword
        Using SecurePassword As New System.Security.SecureString()

            For Each c As Char In strPassword
                SecurePassword.AppendChar(c)
            Next

            Process.Start("mmc", startupParm, strPPAccount, SecurePassword, Domain)
        End Using
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
Please explain purpose of GZIP 4 37
C# class library debugging - Breakpoint will not hit. 8 21
TFS 2015 Access denied. 1 15
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question