473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Permission Denied to my application when copying file to share...

!NoItAll
297 100+
My application uses the following code to run a batch file.
Expand|Select|Wrap|Line Numbers
  1.         Dim DOSProc As New Process
  2.         With DOSProc
  3.             .StartInfo.UseShellExecute = False
  4.             .StartInfo.FileName = "c:\scripts\copyimages.bat"
  5.             .StartInfo.Arguments = Chr(34) & PPSParam.LatestImageFile & Chr(34) & " " &
  6.                                    Chr(34) & PPSParam.Panelname & Chr(34) & " " &
  7.                                    Chr(34) & PPSParam.Comment & Chr(34)
  8.  
  9.             .StartInfo.ErrorDialog = False
  10.             .StartInfo.WorkingDirectory = "c:\scripts"
  11.             .StartInfo.CreateNoWindow = True
  12.             .Start()
  13.         End With
  14.  
The code above was simplified for readability.
It essentially opens a command window and the batch file runs. In this case the batch file is simply copying a file from a location on the local machine to a writable share on the network. I have checked the share and security is set so that Everyone has full access (read/write/delete/etc - all the boxes are checked). If I open a cmd window and run the batch file it works perfectly. But when the above code runs the batch file the copy function gets "Permission Denied"
Any clues what I am doing wrong here?
Could it have anything to do with useshellexecute?
Nov 19 '13 #1
1 1565
!NoItAll
297 100+
The problem turned out to be the fact that my program was started by a service running as system. When that happened my program inherited the system user and shares are not available to system users.
I had to change the way the service called my application (it was a service I wrote) so that it would impersonate the "primary console" user (aka the desktop) in Windows.
In order to use this it required several Win32 APIs. At some point I may submit an article here on how this is done - I wound up writing a DLL, but for now suffice to say that processes started by services will have problems with permissions and security until you run the process impersonating the user logged onto the primary console.
Dec 21 '13 #2

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

Similar topics

1
by: Elie Grouchko | last post by:
Hi I am trying to shutdown a COM+ application from an ASP page implemented using VBScript. I get: Err.Number=0x46 Err.Source=Microsoft VBScript runtime error Err.Description=Permission...
2
by: Wanda | last post by:
Hi all, I have a permission denied error when I tried to copy a file from the local directory to another local directory by using the FSO (FileSystem) Set fso =...
2
by: PM Creyghton | last post by:
I got this error without using frames: First of all, I'm developing an ASP application, and once in a while my activeX components crash or hang, I got page-not-found errors, errors generated by...
2
by: Chris Green | last post by:
I have just installed Postgresql 7.3.4 on my slackware 9.1 system. The installation went fairly smoothly and the server process has started normally:- postgres 21027 20767 0 20:12 pts/5 ...
4
by: Russell Warren | last post by:
I've been having a hard time tracking down a very intermittent problem where I get a "permission denied" error when trying to rename a file to something that has just been deleted (on win32). ...
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
3
by: td0g03 | last post by:
Hello, I am trying to write a code to copy a file which I can do as you can see below. void copy () { // Local Definitions int c; int closeStatus; FILE* spProverbs ; FILE*...
3
by: javalsu | last post by:
I would like to create a popup that reloads with a different page depending which link is clicked on the parent page. Here is the code <script type="text/javascript"> var childWindow ...
3
Ciary
by: Ciary | last post by:
hi all, i'm stuck with a rather rare situation. like most some people will know, i've been busy trying to set an uploaded pdf as background image. now, i encountered a new problem. let me explain...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.