S
someone
I hope someone can help me out here.
I'm using VB.Net and VS .Net 2003 to write code that automates Excel 2003.
Basically, a FileSystemWatcher object watches a folder and it's subfolders
if a user desires. If an Excel generated HTM files is output to the
folder(s), the FSW detects the creation of the file, loads it into Excel in
the background (visible = false), and prints out the document.
I wish I had a copy of the code to paste (forgot to bring some home with
me). Basically, I let the program thread sleep for 1 second (to ensure the
file is fully written out), I just create an Excel Workbook object in code,
add the HTM file to it to load it up, I print the document out, then I set
saved to true so I won't get a prompt asking me to save the file, then I
quit/close the application.
The code itself runs fine. I developed and tested the code in a desktop
application. I could run it, set the program to watch a folder, and
whenever such a file is written to the directory, Excel loads up in the
background, prints it out, and closes itself just fine.
Problem: I needed this code to run in a service so the files will always
print out because someone won't always be logged in. So, I created a
service and copied the code into the service. At first, it wouldn't work.
After debugging the service and looking at task manager, it appears Excel
starts up but for some reason hangs in the background. I noticed while
stepping through the code in the service it appears to stop at the line
where the file is being loaded into Excel and stays there until I shut down
the Excel program running in the background via task manager. Once I do
this, I get some sort of an error message I can't recall at the moment (the
code is inside a try...catch block). After reading up on services and such,
I decided to set the account the service runs under from localsystem to
user. Once I do this, I get asked for a userid and password upon
installation of the service. Once I do this, I can start the service. Once
I do this, the service runs fine and does what it's supposed to i.e. it
prints out the document that's inserted into the specified directory. I
created an administrative account on the local machine and set the service
to this. Funny thing is, it wouldn't work using the admin account on the
machine. Same problem as before (Excel hanging in background upon load of
file into Excel). It seems to work fine when entering an admin account from
the Network/domain.
The code ran fine while in a program and it runs fine fine after I set the
service run account to user while entering a userid/password during the
service install. As such, I'm left to conclude there is some sort of a
security problem. Thing is, the service was initially set to run under the
localsystem account. I thought setting the service to this account type
would let it do anything, but apparently I was wrong. Any ideas on how to
fix this?
Thanks for any advice.
Chris Smith
I'm using VB.Net and VS .Net 2003 to write code that automates Excel 2003.
Basically, a FileSystemWatcher object watches a folder and it's subfolders
if a user desires. If an Excel generated HTM files is output to the
folder(s), the FSW detects the creation of the file, loads it into Excel in
the background (visible = false), and prints out the document.
I wish I had a copy of the code to paste (forgot to bring some home with
me). Basically, I let the program thread sleep for 1 second (to ensure the
file is fully written out), I just create an Excel Workbook object in code,
add the HTM file to it to load it up, I print the document out, then I set
saved to true so I won't get a prompt asking me to save the file, then I
quit/close the application.
The code itself runs fine. I developed and tested the code in a desktop
application. I could run it, set the program to watch a folder, and
whenever such a file is written to the directory, Excel loads up in the
background, prints it out, and closes itself just fine.
Problem: I needed this code to run in a service so the files will always
print out because someone won't always be logged in. So, I created a
service and copied the code into the service. At first, it wouldn't work.
After debugging the service and looking at task manager, it appears Excel
starts up but for some reason hangs in the background. I noticed while
stepping through the code in the service it appears to stop at the line
where the file is being loaded into Excel and stays there until I shut down
the Excel program running in the background via task manager. Once I do
this, I get some sort of an error message I can't recall at the moment (the
code is inside a try...catch block). After reading up on services and such,
I decided to set the account the service runs under from localsystem to
user. Once I do this, I get asked for a userid and password upon
installation of the service. Once I do this, I can start the service. Once
I do this, the service runs fine and does what it's supposed to i.e. it
prints out the document that's inserted into the specified directory. I
created an administrative account on the local machine and set the service
to this. Funny thing is, it wouldn't work using the admin account on the
machine. Same problem as before (Excel hanging in background upon load of
file into Excel). It seems to work fine when entering an admin account from
the Network/domain.
The code ran fine while in a program and it runs fine fine after I set the
service run account to user while entering a userid/password during the
service install. As such, I'm left to conclude there is some sort of a
security problem. Thing is, the service was initially set to run under the
localsystem account. I thought setting the service to this account type
would let it do anything, but apparently I was wrong. Any ideas on how to
fix this?
Thanks for any advice.
Chris Smith