Running exe file from userform

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,232
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I have the following code applied but fails to work.

I would like to run this exe file from within my userform.
The working icon on the desktop read the following info of which i have entered into my non working code.


Target "C:\Users\Ian\Desktop\RUN AS DATE APP\RunAsDate.exe" /movetime 01\03\2013 00:00:00 "C:\Program Files\EPC\epc.exe"


Start In "C:\Program Files\EPC"

The error message shows compileroor / syntax error

Code:
Sub OpenEpc()    Dim strProgramName As String
    Dim strArgument As String


    strProgramName = ""C:\Program Files\EPC""
    strArgument = ""C:\Users\Ian\Desktop\RUN AS DATE APP\RunAsDate.exe" /movetime 01\03\2013 00:00:00 "C:\Program Files\EPC\epc.exe" "


    Call Shell("""" & strProgramName & """ """ & strArgument & """", vbNormalFocus)
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
.
I don't understand the forward slash in the path :
Code:
[COLOR=#333333] /movetime[/COLOR]

Are you attempting to run : RunAsDate.exe
Or ...
epc.exe

Or are you trying to run both ?

You can run a program using the SHELL command ... Shell Outlook.exe .... or .... Shell Notepad.exe ... etc.
 
Upvote 0
Hi,
I am using run as date to keep date the same as it was a trial cd.
I suppose when i click on the icon i go through run as date which does its stuff then it starts the real programme.

Just starting the real item will tell me its expired etc
 
Upvote 0
.
Here is a different approach.

Code:
Option Explicit


Sub ChangeClkDate()
Date = DateSerial(2018, 8, 2)       '<-- Edit for date here
Time = TimeSerial(14, 0, 0)         '<-- Edit for time here
End Sub


[FONT=&quot]To do this you need to be running Excel as an Administrator or you will get a RunTime Error 70 'Permission denied'[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]To run as administrator right click the Excel icon - click 'More' and run as administrator. You can then change the system date with the above macro.
[/FONT]
 
Upvote 0
Hi,
Sorry but im confused as to how / where i apply that to the button ?
 
Upvote 0
.
You would paste the macro into a Routine Module. Place a command button on the worksheet and attache it to the macro. (Right click, ASSIGN MACRO, select "ChangeClkDate".

Save / Close the workbook.

Then follow the instructions how to open the workbook as Administrator.

It will reset your system date / time to the same as in the macro code. You will want to edit the date / time setting in the code to a time prior to the expiration of your trial software.

At that point, you should be able to use the SHELL command to simply run the trial software executable file, without designating a date / time in the software path as you indicated in your original post.
Or if the SHELL command doesn't work ... include the path also to the executable location.
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,109
Members
449,205
Latest member
ralemanygarcia

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