I'm trying to run this .bat file via a job in Task Scheduler, for some reason the application isn't being run.
Is there something wrong with my syntax? I thought the problem could have been not specifying a window name. I've now added that and it still isn't executing. The code is below (names/ paths have been generalised):
ROBOCOPY C:\path\to\file\ Z:\ csvfile.csv /R:2000
START "" \\servername\serverdirectory\serverdirectory2\file.exe
When I run this .bat manually it runs correctly. Could it be down to permissions?
Thanks!
Related
I have a batch file that's in my desktop and it works properly when I execute it using double click. But when I execute it using a task scheduler or run as administrator, the working directory changes to C:\Windows\system32 and it doesn't work properly.
What's the reason why it happens and how do I retain the working directory?
Put this line at the top of your bat file:
pushd %~dp0
See this post for details
Difference between "%~dp0" and ".\"?
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
The command
cd %SOME_DIR%
in Far console changes current directory.
But executing the same command in batch script from Far does nothing. Is it possible to switch directory using batch script in Far?
Far manager runs a batch script (.bat) in a child process and cd command only modifies the environment of the current process. It can't touch the environment of the parent.
How would I go about making a Jenkins server start a .bat file, that runs forever as it starts a server program, without having Jenkins run forever until the bat file is ended manually or by error?
Could this be solved by making Jenkins call a bat file which calls the server bat file thar runs forever?
You need to detach execution from the main process, similar to the & operator in Linux.
If you bath file is named run-forever.bat, then create another batch file named forever-starter.bat that does this :
#start "" cmd /c run-forever.bat
In hudson, after running a .bat script my slave refuses to run anything that comes afterward. It instead just said that it finished with a success.
Trying do a
call yourscript.bat
instead of just a
yourscript.bat