Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now