Solved

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

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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