Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:52:02+00:00 2026-06-06T11:52:02+00:00

I have a vbscript file that I want to run in my vb.net application.

  • 0

I have a vbscript file that I want to run in my vb.net application. In the application, the script ‘must’ use a process. The reason is that it’s actually being called from a windows process. In order for me to execute the vbscript manually, I have to right-click on the shortcut and select ‘run as administrator’.

How can I emulate this using vb.net? Currently the execution works because I tested it with it only creating a text file. Also, I want to assume that the user is in the administrators group and don’t want them to have to login each time because it will execute every minute.

My code:

Dim foo As New System.Diagnostics.Process
foo.StartInfo.WorkingDirectory = "c:\"
foo.StartInfo.RedirectStandardOutput = True
foo.StartInfo.FileName = "cmd.exe"
foo.StartInfo.Arguments = "%comspec% /C cscript.exe //B //Nologo C:\aaa\test.vbs"
foo.StartInfo.UseShellExecute = False
foo.StartInfo.CreateNoWindow = True
foo.Start()
foo.WaitForExit()
foo.Dispose()

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:52:04+00:00Added an answer on June 6, 2026 at 11:52 am

    The class ProcessStartInfo has two properties that can be used to define the user name that will run your script

    ProcessStartInfo.UserName
    ProcessStartInfo.Password

    Please note as from MSDN:
    The WorkingDirectory property must be set if UserName and Password are provided. If the property is not set, the default working directory is %SYSTEMROOT%\system32.

    The Password property is of type SecureString. This class need a special initialization code like this:

      ' Of course doing this will render the secure string totally 'insecure'
      Dim pass As String = "Password"
      Dim passString As SecureString = New SecureString()
      For Each c As Char In pass
         passString.AppendChar(ch)
      Next   
    

    So your code could be changed in this way

    Dim foo As New System.Diagnostics.Process   
    foo.StartInfo.WorkingDirectory = "c:\"   
    foo.StartInfo.RedirectStandardOutput = True   
    foo.StartInfo.FileName = "cmd.exe"   
    foo.StartInfo.Arguments = "%comspec% /C cscript.exe //B //Nologo C:\aaa\test.vbs"   
    foo.StartInfo.UseShellExecute = False   
    foo.StartInfo.CreateNoWindow = True   
    foo.StartInfo.UserName = "administrator"
    foo.StartInfo.Password = passString
    foo.Start()   
    foo.WaitForExit()   
    foo.Dispose()  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a vb script using process.start() as another user that have
I have a little problem with a simple vbScript. The script has to run
I have a VBScript script that looks like this: Const ForAppending = 8 Set
I have a VB script which I want to run with python27, when I
We have a custom action that we want to run ONLY on a major
I have a vbscript file that will open a document with the correct program
I have a vbscript file A that will call another vbscript file B. File
I have a text file that is being processed as part of a batch
We have an old process (VBScript) that reads a common mailbox and processes certain
I have a vbscript file that is reading a file and sending each line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.