Batch Job on Windows Server 2012 Access denied - batch-file

The batch file is used to execute php files.
Unfortunately whenever i execute the batch file. Access denied error is appear.
below is the source code of my batch file.
set VTIGERCRM_ROOTDIR="C:\Program Files
(x86)\vtigercrm600\apache\htdocs\vtigerCRM" set PHP_EXE="C:\Program
Files (x86)\vtigercrm600\php\php.exe"
cd /D %VTIGERCRM_ROOTDIR%
%PHP_EXE% -f vtigercron.php
pause

It is the problem of the php file itself. Not related to windows server security setting.
Sorry for the trouble.
Thank you.

Related

How do I stop my batch file and pushd from referencing the unc when opening cmd.exe?

I'm trying to run a batch file from a local Windows server that calls on computers in my domain to pull from the shared folder and run an exe. I'm not sure if my script is trying to do too much or too little.
So I run the below batch locally
X:\pstools\psexec.exe \\Computer -d -u DOMAIN\user -p password -i \\SERVER\test\testfile.bat
and testfile.bat:
#echo off
pushd \\SERVER\test\
call program.exe
popd
When I run the script, psexec runs and I get a confirmation that testfile.bat was started on target computer. On the targeted computer nothing happens. If I navigate to the share on the targeted computer and run testfile.bat, I get "CMD.EXE was not started with the above path as the current directory.UNC paths are not supported. Defaulting to Windows directory." From there the computer runs the called .exe with no issues.
If I target this towards another server in my domain it executes perfectly, but not on domain computers. I thought maybe a GPO issue, but I can't find a solution.
Thanks for any knowledge or help provided!
Thanks for all the tips everyone! This is how I ended up getting it working for anyone who might have the same issue.
Script on Server:
x:\pstools\psexec.exe \\Computer(or text file with computers listed) -d -s cmd /c (batchfile.bat)
Similiar to what I was trying before, but to ensure you run the command line as System on the remote PC you have to specify "-s cmd". The /c copies the batch to the remote system to run locally. You can include a "-f" to overwrite if you've already copied it previously. I just put the batchfile in the pstools folder.
Batchfile.bat:
pushd \\networkdrive
call (.bat/.cmd/.exe/etc.)
popd
I disabled the firewall for testing, but I believe you have to open TCP-445/UDP-137 for PSEXEC. Otherwise, that's it. Super simple solution.

Running WinSCP script displays nothing

I'm trying to use WinSCP through script to synchronize a local folder with an FTP one.
I created a script a below
open ftp://<user>:<pw>#ftp.myserver.com/initFolder/
synchronize remote -delete C:\Data\backup /initFolder/
exit
And I run it with the command
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\data\bin\log\WinSCP.log" /ini=nul /script="C:\data\bin\myScript.txt"
However, it appears nothing is happening. The command exists immediately with no message (either error or some processing / confirmation, etc).
Also no log file is created either.
What am I doing wrong?
Please advise
Indeed, with the command-line syntax you are using, WinSCP runs without any GUI.
If you are starting WinSCP from a console window (e.g. from Windows batch file), use winscp.com instead of winscp.exe. winscp.com is a console application. You will see any errors in the console.
Alternatively, you can add /console switch to winscp.exe command-line to make it open its own console window. Though you will rarely want this.

Command Line Installation with SCCM 2012

I have a few applications that I am trying to deploy with SCCM 2012 but the installations are failing through the application catalog. So what I have for the deployment type is a script installer. I have "cmd.exe" (Without quotations) in the Installation program field and "Installer.bat" in the installation start in field.
When I look at the ccmcache folder, all the contents over that application are there but the following error displays the Software Center:
0x8007010B(-217024629)
I have done some reading online and the "10B" is a common command line error for invalid directory. I have tested the batch file when hard coding a path but my question is, how can I edit the batch file or SCCM to pull from the CCMCache path where the files are downloaded to on the local client? Currently the Batch File is simply:
#echo off
ApplicationName.exe
Do I need to edit the file to cd into the CCMCache folder where the files are placed? How can I get the batch file to run the executable that is downloaded to the CCMCache folder?
Thank You!
You need to have the full path to the installation in your script
#echo Off
\\path to .exe
The way the command is written will not be able to find the .exe file. You need to add the full unc path to the .exe into your .cmd file. You should have your installation .exe and .cmd file in the same location on the distribution share
Recommended Solution:
Before starting, since you are only launching an exe with your batch file, I would recommend just using your ApplicationName.exe as your command line parameter in SCCM instead of using a batch. This will eliminate the need to engineer any further.
Modifying the existing solution to work:
If you do still want to use a batch file, keep a few things in mind. The syntax you are using to launch the batch file will not work. I would recommend just using the batch file name "installer.bat" as your command line. If you still want to preface the batch with the cmd.exe, you absolutely need to use the /c switch with it
cmd.exe /c installer.bat
If you don't use /c the console host will only open to a promopt and not execute your batch.
This is not an ideal solution though because using "cmd.exe /c" will set your working directory to the location of cmd.exe (ie "C:\windows\system32") and since your content is staged in ccmcache, you will need to specify its location within your batch. To do this, you would use %~dp0 variable which gives you the directory the current batch is running from. This means modifying your batch to read
#echo off
%~dp0ApplicationName.exe

Executing WinSCP command in batch file

I am new to batch and trying to execute a script I wrote, essentially I want to go to a remote server copy the files there and transfer it to a folder in my local directory. I am executing the bactch file but nothing is being copied any suggestions would be great. This is my script
open sftp://site:#ftp.site.net -hostkey="server finger print"
synchronize local C:\Users\localdirectory\Desktop\test2 /Home/folderA/NewFiles
exit
I am positive all the information is correct because that's how I login with WinSCP. I got this script from https://www.youtube.com/watch?v=ndvEYOQLc4c
This is WinSCP script. There's no batch file in your question.
To run WinSCP script, use for example:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /script="C:\path\to\winscp.txt"
(assuming your WinSCP script is in C:\path\to\winscp.txt).
You can put the above command to a batch file.
See guide to scripting with WinSCP.
You can also have WinSCP GUI generate both the script and batch file for you (or even a batch file that directly contains the WinSCP commands).

SSIS: Execute Process task can't execute FTP

i'm trying to transfer my data from TXT that i generate in a Data flow task to FTP library and can't do it
If i use Execute Process Task i must execute a File1.bat:
#echo off
ftp -s:fileName.txt -n
and fileName do it:
open
172.16.60.223
user
username
password
put \\dappwstd2008\paso\Esteban_Entregas\Clientes\fileName.txt BICCONVER1/CVCUREL
close
bye
If i execute the file1.bat works correctly, but can't do it with SSIS.
i tried to do the following:
Execute Process Task
Executable: D:\Users\MyName\Desktop\file1.bat
Argument: "fileName.txt"
[Execute Process Task] Error: In Executing
D:\Users\EDonosoV\Desktop\file1.bat" ""fileName.txt"" at "", The
process exit code was "2" while the expected was "0".
i change success value to 2 and work but CMD do nothing
Any solution?, i tried using the code of the TXT in FTP Task and have problem with RemotePath because my destiny is a library and can't open it
Thanks!
Try copying your filename.txt into C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn (If you are using SSIS 2010)
Similar path for 2008 or 2014
This is the "Working Directory" when you run BIDS
Or just fully qualify the path
I solved it!
i must write the route of the folder with .bat and .txt inside in Working Directory
Executable: D:\Users\MyName\Desktop\file1.bat
Argument: "fileName.txt" (This file inside Desktop or the same folder of file1.bat)
Working Directory:D:\Users\MyName\Desktop\
And work it, transfer my Flat file to FTP!
Thanks for the comment and i hope help someone else with the same problem!

Resources