473,545 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing MSAccess dll's from a Windows Scheduled Task

6 New Member
I have a bit of a problem I'm hoping someone can shed some light on...

I have a VB.Net console application written in VS 2003 that produces a .exe file that now sits on a Windows 2000 server directory. This exe does the following 3 things:

1.) Using the VB Interaction SaveSetting() method, it programmaticall y updates the system registry under the HKEY_CURRENT_US ER\SOFTWARE key and saves a directory location used by a PDF driver (so that the pdf driver does not prompt for a location).

2.) opens up an instance of a local MSAccess database (i.e., set objAccess = New Access.Applicat ion(c:\mydataba se.mdb))

3.) Uses the DoCmd.OpenRepor t method to create a physical .pdf report to the location specified above in step 1. Then the report is emailed out to a group of users.

When I'm logged on to the Windows 2000 server as my user i.d. and I double click the .exe file, everything works perfectly.

However, I'm running into problems when trying to automate this and kick off the .exe file with a Windows scheduled task. If I run the scheduled task as my i.d., I do not get past step 2 above as it keeps giving me the following error:
"System.Unautho rizedAccessExce ption: Access is denied." It appears that my userID cannot create a new instance of MSAccess but only when run through the scheduled task.

If I run the scheduled task as NT AUTHORITY\SYSTE M, I get an error message on step 3 above with the following error message:
"There was a problem retrieving printer information for the Win2PDF on PDFFILE:. The object may have been sent to a printer that is unavailable."
In this case it appears that I cannot save registry settings as the NT AUTHORITY\SYSTE M user for the pdf printer.

So my questions are first, does anyone know why I cannot create an instance of MSAccess when using the scheduled task. And second, why can't I save registry settings when I run the .exe through a scheduled task as the NT AUTHORITY\SYSTE M user?

Thanks in advance,

John
Jul 18 '08 #1
9 3764
kenobewan
4,871 Recognized Expert Specialist
Most of your questions come down to permissions. Your question is confusing in that it appears to associate saving a db file with installing db software. The install works with an account that suggest using windows authentication without impersonation.
Jul 20 '08 #2
jdaelhousen
6 New Member
Most of your questions come down to permissions. Your question is confusing in that it appears to associate saving a db file with installing db software. The install works with an account that suggest using windows authentication without impersonation.

Yes, it does come down to permissions which is what I'm trying to figure out. Let's start simpler:

I'm an admin on the server. If the .exe works fine and can open instances of MSAccess when I double click it, why does it fail to instantiate MSAccess when a scheduled task runs the executable as the NT AUTHORITY\syste m user? What am I missing here?

Thanks,

John
Jul 21 '08 #3
kenobewan
4,871 Recognized Expert Specialist
Yes, it does come down to permissions which is what I'm trying to figure out. Let's start simpler:

I'm an admin on the server. If the .exe works fine and can open instances of MSAccess when I double click it, why does it fail to instantiate MSAccess when a scheduled task runs the executable as the NT AUTHORITY\syste m user? What am I missing here?

Thanks,

John
You have hit the nail on the head - Access is run under your admin account but not the anonymous account. Are you planning to automate this task on any other machines/servers?
Jul 22 '08 #4
jdaelhousen
6 New Member
You have hit the nail on the head - Access is run under your admin account but not the anonymous account. Are you planning to automate this task on any other machines/servers?
I apologize, my previous reply was a bit confusing after I reread it. First to answer your question, I am planning to automate this task with the scheduled task only on the server that the exe is currently sitting. It will not be deployed anywhere else.

But I think I might have miscommunicated what's actually going on here. Let me take a step back and reconfirm what's going on:

If I double click the .exe everything works fine.

If the scheduled task executes the .exe as my user ID I get the "Access is Denied" error (can't instantiate MSAccess).

If the scheduled task executes the .exe as the NT AUTHORITY\SYSTE M user, the application can instantiate MSAccess, but I get other errors mentioned in my original post about reading registry settings. Therefore, I'd like to solve this problem if possible by executing the scheduled task as my i.d. and get past this inability to instantiate MSAccess.

Thanks,

John
Jul 22 '08 #5
kenobewan
4,871 Recognized Expert Specialist
NP. This is why I mentioned impersonation in my first post, I believe now that this may be the key to your problems. An example might help:
User Impersonation in .Net.
Jul 23 '08 #6
jdaelhousen
6 New Member
NP. This is why I mentioned impersonation in my first post, I believe now that this may be the key to your problems. An example might help:
User Impersonation in .Net.
Thanks, kenobewan. I'll give this a whirl later tonight when I get some time and reply back with my results. It does appear from first glance that this might be the issue.

Thanks again.
Jul 23 '08 #7
jdaelhousen
6 New Member
Well the impersonation code didn't seem to work. After referencing the ImpersUser dll in my project, I tried running the 1 line of code to impersonate as the NT AUTHORITY\SYSTE M user. No errors were thrown so i'm assuming that the impersonation as NT AUTHORITY\SYSTE M went through ok, but I still could not open up the access database. I'm really stumped here.
Jul 24 '08 #8
kenobewan
4,871 Recognized Expert Specialist
You are having no joy because, not an insult, you are new to this. To progress with this prob you'll need to learn much more about .net.

This is time consuming in the short term, but you'll benefit in the long run if you face other situations like this. The alternative is to hand this over to a developer.

The reason I am saying this is not be unkind, but we are starting to go around in circles here. I believe that there is enough info in my posts to solve this problem.
Jul 25 '08 #9
jdaelhousen
6 New Member
You are having no joy because, not an insult, you are new to this. To progress with this prob you'll need to learn much more about .net.

This is time consuming in the short term, but you'll benefit in the long run if you face other situations like this. The alternative is to hand this over to a developer.

The reason I am saying this is not be unkind, but we are starting to go around in circles here. I believe that there is enough info in my posts to solve this problem.

No offense taken, however I am a developer and know how to write .net exe modules and have been doing so for several years. What I'm not familiar with are account permissions because I'm not a network administrator. And don't take this the wrong way because I appreciate your help, but other than the impersonation class that didn't fix the issue, you didn't suggest anything that I haven't already tried. So I think I need to present my issue to another message group. There has to be someone who has faced this same exact problem before. Thanks again.
Jul 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2275
by: Christina | last post by:
Dear All, How can I pop up the windows task scheduler inside of my .net application? Such as I have a button called Schedule Now, after clicking it, the Add Scheduled Task window will pop up, just like clicking from Control Panel -> Scheduled Task -> Add Scheduled Task. Appreciate ahead for any of your suggestions. Thanks.
6
8223
by: John Bowman | last post by:
Hi, I have a C# app that needs to launch the "Add Scheduled Tasks" wizard found in the control panel "Scheduled Tasks" applet. I realize that this "applet" really just opens the tasks folder, but I need to launch the add tasks wizard inside the folder. Does anyone have any ideas of how to do this? I can't find anything in the MSDN...
3
2137
by: nkunapa | last post by:
Hi: I am looking for any ideas/comments/suggestions on how a Windows Service kind of functionality can be acheived from a web application which which will run under IIS or for that matter any application server say Tomcat. I have a Windows service which should run every half hour and call four different methods in a Web Service in serial...
9
2264
by: helpful sql | last post by:
Hi all, I want to write a .Net solution that I would like to run as a scheduled task in windows. I am not going to need any user interface. What I don't understand is what kind of project I need to create in Visual Studio for this solution. Is it Console App, Windows App, Class Library or Windows Service? Please help. Also any sample code...
6
2773
by: arun.hallan | last post by:
Hi, I want to run a webservice method every night at a specified time, say 10pm. The current way i thought of doing this is to have a windows service and a timer which checks the time every minute and when it gets to 10:00 it fires off the webmethod. Is this the best way to do it? If not, does anyone have any
1
7478
by: Myster Edd | last post by:
I have a strange problem that I think deals with security on SQL 2005. I have a scheduled task that runs on a Windows 2000 machine. It calls a vb script which creates a connection to SQL Server. We migrated a database from SQL 2000 to 2005 which is on a different box. I changed the connection in the vb script to use the new sql server. ...
0
7467
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7807
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1879
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.