Solved

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

Posted on 2011-03-23
4
709 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

Industry Leaders: 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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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