Solved

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

Posted on 2011-03-23
4
706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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