How to launch a .cmd file from Excel (VBA)

ericlbt

New Member
Joined
Mar 29, 2019
Messages
6
Hello,

I am trying to launch a .cmd file from Excel (VBA).

Unfortunately, no matter what I try, nothing works.


I want to launch : control.cmd

Which is located in : \\Team2\Research\

Full path is: \\Team2\Research\control.cmd
Not on my C: drive


I played around with shell cmd.exe, the command, the path but never found the solution.


Any help will be much appreciated.
Thank you.

Eric
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Did you try this approach ...
VBA Code:
Sub ericlbt()
    Dim oShell As Object
    Set oShell = WScript.CreateObject("WSCript.Shell")
    oShell.Run "cmd /C \\Team2\Research\control.cmd"
End Sub
 
Upvote 0
Please change the code of my previous post by deleting the Wscript. part:
Rich (BB code):
Sub ericlbt()
    Dim oShell As Object
    Set oShell = WScript.CreateObject("WSCript.Shell")
    oShell.Run "cmd /C \\Team2\Research\control.cmd"
End Sub
 
Upvote 0
Please change the code of my previous post by deleting the Wscript. part:
Rich (BB code):
Sub ericlbt()
    Dim oShell As Object
    Set oShell = WScript.CreateObject("WSCript.Shell")
    oShell.Run "cmd /C \\Team2\Research\control.cmd"
End Sub
Hello GWteB,

Thank you for your quick reply.

It does not work: Permission denied (Error 70)

I guess I don't have access to the "Team2" drive.

I will check with my colleague and will let you know what happens.
 
Upvote 0
Hello GWteB,

Thank you for your quick reply.

It does not work: Permission denied (Error 70)

I guess I don't have access to the "Team2" drive.

I will check with my colleague and will let you know what happens.
I guess there is no access issue as I can execute the command when I use a shortcut on my desktop.
 
Upvote 0
I guess there is no access issue as I can execute the command when I use a shortcut on my desktop.
In a network environment you can't be sure about that, since there's most likely a "network workspace manager" active which often imposes certain restrictions on the user.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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