How to pass arguments to command prompt opening a shortcut?

Leafzer

New Member
Joined
Apr 7, 2022
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I found the following on an old thread to open up shortcuts, this helped with a certain issue I was having in opening up local command prompt, the problem is I'm just starting out with VBA and I'd like to know how can I take this and pass arguments to the command prompt window? I went into the documentation of the .DoIt since I read it was the FolderItem.Verbs.Item(0).DoIt is the function that actually opens command prompt, but I'm not exactly certain how to pass an argument into it even after reading the documentation.

Any help is appreciated here.

As an end result I'm trying to get a username after clicking the commandbutton, inputting that user name and running commands. I already understand how to get an input and how to store/pass the input. But I need to know how to send those inputs to command prompt once it's opened.


VBA Code:
Sub OpenFile()

  Dim FileName As Variant
  Dim FolderItem As Object
  Dim FolderPath As Variant
  Dim oFolder As Object
  Dim oShell As Object
  
    FolderPath = [B]"C:\Documents and Settings\Admin.ADMINS\Desktop"[/B]
    FileName = [B]"Solitaire.lnk"[/B]
    
      Set oShell = CreateObject("Shell.Application")
      Set FolderItem = oShell.Namespace(FolderPath).ParseName(FileName)
    
      FolderItem.Verbs.Item(0).DoIt
    
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,215,528
Messages
6,125,342
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top