Link to home
Start Free TrialLog in
Avatar of stengelj
stengeljFlag for United States of America

asked on

Execute Run Command on Server (VB)

I am running II6, .NET 1.1 and using VB.

From a function in a .aspx page, is it possible for me to execute a Run command on the server?

In other words, how could I get the server to run the following using a button on a web page:

"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" c:\myData.mdb /xmac_myMacro /cmd 129

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ahmad1012
Ahmad1012

In the suggestion provided by dstanley9 u will have to import the System.Diagnostics before u can run his code.
Avatar of stengelj

ASKER

It seems like both of your suggestions are really the same thing.  Ahmad1012's is just an abreviated way to do it.

However, it's not working for me.  It seems to launch MSACCESS using the Network Service account (I can see it appear in task manager) but it doesn't load the macro.

I also get some error in the event view.  I'm thinking that the Network Service account isn't able to run MSACCESS.

Here are the EventIDs:

Failed to connect to server. Error: 0x80070005

Detection of product '{90150409-6000-11D3-8CFE-0050048383C9}', feature 'OfficeUserData', component '{4A31E933-6F67-11D2-AAA2-00A0C90F57B0}' failed.  The resource 'HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\MS Access Database\' does not exist.

Failed to connect to server. Error: 0x80070005

Detection of product '{90150409-6000-11D3-8CFE-0050048383C9}', feature 'AccessUserData', component '{8ADD2C98-C8B7-11D1-9C67-0000F81F1B38}' failed.  The resource 'HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Access\UserData' does not exist.

The reason Ahmad1012's  doesn't work is you need to use the ProcessStartInfo in order to pass the startup parameters (which would start the macro as you suggested).

Also, like I said, the ASP.NET app needs to be running as a user that has access to Access (no pun indented) and any data files it opens.  You can use impersonation to do this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaspnetimpersonation.asp

dstanley9 has got it right.
Accessing MSAccess doesn't seem to be the problem.  I seems like when Access first runs for a user, it needs to create some registry entries.  

I'll try the impersonation thing.

FYI.  I think this should work:

System.Diagnostics.Process.Start("myProgram.exe","myParameters")
So, I had to find a different approach.  I was able to launch Access but it would run my macro right (not your fault) so your suggestions were correct for launching the app which will be useful to know for another project I have.

I ended up using a script that will send an Access report to a Snapshot file and then display the report in the browser window.  This allows my users to print some custom shipping labels to the correct printer with the correct settings which was my ultimate goal in the first place.

Thanks for the help though.