Why Batch Process not working by Task Scheduler User Administrator? - batch-file

I have a process for ETL, in a .bat file wich:
copy .xlsx file to a directory
open the excel file by progress
copy the information to progress database
When I run the .bat file by the user: TableauAdmin in the explorer:
it works fine !
TableauAdmin appears as the owner of the .log files
Then I created a scheduled task with the owner: TableauAdmin, and user to run the task: TableauAdmin, in Windows Server 2012. With the Highest privileges, wheter or not the user is loged ...
If I try to run the task I got this error:
Error occurred while accessing component property/method: open.
Microsoft Excel cannot access the file
'd:\ses\dat\FacturaMes-240817.xlsx'. There are several possible
reasons: Error code: 0x80020009 d:\ses\pro\sescargaexcelbd.p (5890)
And now, the owner of the .log files, is the user "Administrators".
Also, I am writing in the log files the %USERNAME% and appears "TableauAdmin"!!!
Is not working the progress-office-excel option by changing the account TableauAdmin to Administrators where is included TableauAdmin.
What to change to every thing works fine?
Today I changed the User that runs the Task to Administrators...
Now everything is working fine, but the user it is running it does not appears Administrators,
The User that appears running the process is another Administrator....
So the Excel File is owned by Administrators
And opened by Administrators
But is running by other Administrator, not TableauAdmin....
Why is running OK now?

Have a look at this link -> https://blogs.msdn.microsoft.com/dataaccesstechnologies/2012/12/19/error-microsoft-office-excel-cannot-access-the-file-while-accessing-microsoft-office-11-0-object-library-from-ssis/
For Windows 2008 Server x64: Create the following directory:
C:\Windows\SysWOW64\config\systemprofile\Desktop
For Windows 2008 Server x86: Create the following directory:
C:\Windows\System32\config\systemprofile\Desktop

Related

SSIS runs package that runs powershell script but SSMS don't

I have a package on SSIS that executes a .BAT file that consequently executes a PowerShell file, which brings the file metadata from a folder, generating a CSV file.
I already granted access to the folder for the SQL Server Agent user, but it didn't work.
When I run the package on SSIS, it works correctly! However, if I execute the same package through a JOB in SSMS, it ends the step, but the .BAT file was not executed, or if it was, the Powershell file did not, because after the execution the CSV file is "1kb", no data.
Am I forgetting something?
SSIS package (portuguese language):
[EDIT 1]
A strange thing that I noticed, was that we have 3 packages scheduled by SSMS, but only one of them that doesn't work, which is the one mentioned in the question. But I can't find out why or what the difference is to others.
2 packages extract information from Sharepoint and work on SSMS, but this other package that extracts metadata from files does not.
Check the job step's "Run As" value, which is a "Proxy" (visible in the Object Explorer in SSMS.
Open the Proxy (SQL Server Agent >> Proxies >> SSIS Package Execution). It will list a Credential Name.
Open the Credential (Security >> Credentials). It will list an Identity. That's the user whose security needs to be configured.
Open a cmd window and run runas /user:<userGoesHere> cmd and enter the password when prompted. See the documentation of runas here
Now, it opens a second cmd window which runs under this user used in the SQL Server Agent. Execute your batch file and see if you'll catch any error.
Also, the process you're running may require the user to have Log on as a batch job permission. Run secpol.msc from an admin account and add this user to this permission.

Text File Permissions Issue

What is the default SSIS Account that is used in SSIS packages.
In one of my packages I have a Data Flow task that creates a flat file. A BAT file later runs and creates a file based on information in that .txt file. If I execute the .BAT in Windows Explorer it runs fine. When SSIS tries to execute it I can see the CMD window open and it tries to access the txt file and isnt able to. Says "Unable to access nameoffile.txt"
I assume the issue is that the permissions are probably inherited by the SSIS user account so I am trying to figure out which account that is.
If you are running it from the IDE then it uses your permissions. Most likely the problem is that your file is locked by some other process in your SSIS package. To verify:
Add a PAUSE to your batch file to make it wait for any key.
Run your package. While the dos prompt is waiting, go into windows explorer and run your batch file again - you'll find the same error.
I changed the attrib value in dos for that specific folder by attrib -r -s and it worked. It thought it was read-only.
I am using Windows Server 2012 server, with a SQL Server 2012 database.
Adding Modify, Read, Write permissions to the folder containing the required file to the NETWORK SERVICE user seems to work for me.

CakePHP Shell "could not start" from Scheduled task and Windows 2003 Server

I am trying to run a CakePHP Shell script through the Scheduled Task of Windows 2003 server and I'm finding that the task Could not start.
When I run it manually from the Command Prompt it works well:
C:\Inetpub\wwwroot\CakePHP\lib\Cake\Console\cake mail read
The Scheduled task Run field is exactly the same and the Start in is set to:
C:\Inetpub\wwwroot\tickets\app
The Run as field is set as the computer admin which has all permissions (not the ISS user)
Scheduled Task log shows this message when trying to execute it:
"Ticket Mail System.job" (cake) 13/12/2012 07:15:00 ** ERROR **
Unable to start task.
The specific error is:
0x80070005: Access is denied.
It seems it is a permissions problem.
I have tried to give over the lib/Cake/Consol/cake.bat file all permissions for both users, the IIS 6 user and the Internet Guest Account user, but still doesn't work.
Any idea which could be the cause?
It worked well over Windows 7 but it didn't on Window 2003 Server.
Finally, I tried it adding .bat after calling the Shell and it works.
I had to put this in the Run field:
C:\Inetpub\wwwroot\CakePHP\lib\Cake\Console\cake.bat mail read
It seems Windows 2003 needs the .bat at the end...
I found it at: http://www.geekyboy.com/archives/376
Thanks guys, this got my issue solved.
found that my ".bat" file instead had the extension ".CMD" which seemed to work fine up until now.
fixed it by renaming the file extension and changing the directory in the task scheduler.(because it still had the ".CMD" extension.

Running batch file on Remote Desktop login fails

As just extra protection, I am wanting to backup remote sql db to my location nightly. There is no VPN so...
I created a user on the 2008 db server for the sole purpose to log on from my office and download the db bak file nightly. Gave this user read permission on the backup directory (T:\Backup) and added to the remote users group.
I created a Automated task on my workstation that calls a rdp file that successfully connects to the db server as this user.
The rdp file specifies in the "Start a program" tab the following path:
C:\Windows\System32\mstsc.exe T:\Backup\copydb.bat
I have tested both parts:
1) Double-clicking the rdp file will login automatically. (WORKS)
2) I can then manualy open the dos prompt and run the bat file. (WORKS)
However, the bat file does not seem to execute on connection . There is no cmd window. I can douple-click on the bat file and the cmd window will flash and go away but does not execute. The only way I've been able to get it to execute is to open the prompt and then the file.
I thought that's what this would do:
C:\Windows\System32\mstsc.exe T:\Backup\copydb.bat
What am I missing?
This might be your problem.
Refer to this MS support article You cannot create a terminal server session to a Windows Server 2008-based computer by using an .rdp file that runs an initial program
To work around this problem, add the program path to the RemoteApp Programs list. To do this, follow these steps:
Click Start, click Run, type remoteprograms.msc, and then click OK.
In the actions pane, click Add RemoteApp Programs, and then click Next.
Click Browse, locate the program that you want to approve, click Next, and then click Finish.

Running batch job using TeamCity fails, but Manual command prompt works

I am getting this error message running a batch job with TeamCity. The batchjob is copying files from TeamCity Server to another server(server2). Have checked multiple times, the folders have all the rights permissions needed and this works fine (copies files between servers) when the batch job is run manually from command prompt. I have this error for each file that needs to be copied.
error MSB3021: Unable to copy file "..\bin\Release\Boo.Lang.Compiler.dll" to "\Server2\DestinationFolder\". Could not find a part of the path '\Server2\DestinationFolder'.[10:54:32]: Creating directory "\Server2\DestinationFolder".
I tried few things, but issue remains unresolved. Thanks for your input.
TeamCity build Agent is running as System user account that has no access to the network resources, you should change the service user to an account that has network permissions, like your Administrator account.
See also the related question.

Resources