Run a Batch FIle
Hello - I think, Jason's article is going to help you for sure.
http://blogs.catapultsystems.com/jsandys/archive/2009/08/30/current-directory-in-configmgr-programs.aspx?id=18&List=0d93faf7-32c9-431c-ba49-71dc4c422a16&ItemID=18Anoop C Nair - This posting is provided "AS IS" with no warranties or guarantees, and confers no rights. |Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually
answer your question. This can be beneficial to other community members reading the thread.
May 6th, 2011 10:20pm
I have created a package and TS to first copy a folder and its contents to a desktop. Inside that folder, among other things is a batch file. Once the batch file is copied down, how do I run that batch file using sccm. I tired adding "run command line",
but that errors out. Granted I am assuming "run a command line" would refernece the desktop itself. So when I add the "run command line" I have in there c:\Quest\batch.bat
Thoughts?
Free Windows Admin Tool Kit Click here and download it now
May 7th, 2011 1:12am
If I am right, this article is talking about running the batch file from the DP. The batch file I am trying to run, I already copied to the desktop. Now I need it to run on the desktop. I just want sccm to tell the batch to run.
May 7th, 2011 1:20am
I think you can start from below search. There r lot of options available . Se, http://social.technet.microsoft.com/Search/en-US/?query=batch%20file&rq=meta:Search.MSForums.GroupID(2a118fc8-6e85-4637-821e-4231d2eef7c9)+site:microsoft.com&rn=All+System+Center+Configuration+Manager+ForumsAnoop C Nair - This posting is provided "AS IS" with no warranties or guarantees, and confers no rights. |Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually
answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
May 7th, 2011 2:28am
Granted I am assuming "run a command line" would refernece the desktop itself.
What does that mean? Reference the desktop? Do you mean that it would automatically run from the desktop?
So when I add the "run command line" I have in there c:\Quest\batch.bat
If the batch is on the desktop, why doesn't that command-line contain the desktop folder? That is a fully qualified path that is specifically not in any desktop folder.Jason | http://myitforum.com/cs2/blogs/jsandys | Twitter @JasonSandys
May 7th, 2011 8:36pm
What I mean is when I add "run a command line" does the command line runs on the computer I have applied the TS to, or on the sccm server???
When I said desktop, I was referring to the computer, not the desktop folder. The location of that batch file is located at c:\Quest
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2011 2:44pm
Lets try and make this a little more simple...
I have a batch file located on all the desktops in a location. I want to launch that batch file using sccm. How do I start that batch file. Lets say the file is called batch.bat and it is located at c:\Quest\
How to I start this batch file???
May 8th, 2011 2:48pm
If the target of a command-line already exists on the system, you can create a package without specifying any source files. This is essentially an empty package meant only to contain a program. Then, for the program, specify the path to your batch file just
like running it manually.
Thus, based on the above info, your command-line in the program would be
c:\quest\batch.bat. You then advertise this package and program to the systems where you want it to run via a collection and it will run on those systems per your advertisement settings.Jason | http://myitforum.com/cs2/blogs/jsandys | Twitter @JasonSandys
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2011 3:51pm
Any other ideas?
May 9th, 2011 3:50pm
Depends on a lot of things. Are you seeing errors? Where? Can you at least screenshot you configuration and provide your batch file? We're kind of shooting in the dark without knowing how you've configured things and where you are having problems.Jason | http://myitforum.com/cs2/blogs/jsandys | Twitter @JasonSandys
Free Windows Admin Tool Kit Click here and download it now
May 9th, 2011 4:39pm
I did as you suggested, adding a program without indicating source files. For the last few hours, it has just been "install Pending" to my DP. Curious, I added sources files in another package, and it installed right away.
Thats one issue.
If I do not add a DP, (you never mentioned that, so I wanted to test just to make sure) it errored out, as I suspected it would.
So, to start again I guess...What I am trying to accomplish is...
Copy a folder (in the folder it has a couple of files which include a .bat and a .exe and a .iss config file). That part completes perfectly.
So, now that I have that folder on the computer, I need to run the batch file that will install the .exe using setting from the .iss file.
If I login to the computer I am testing, and either double click on the .bat or run the .bat from a command line, everything works perfectly.
If I try and run the .bat file using sccm task sequences, it fails.
the BATCH file contents:
pushd
C:\Quest\QuestAPlus.exe /s /f1"%CD%\setup.iss"
popd
I have included the errors that pop up trying to use a command line to have the .bat run as part of a TS that included coping the folder then trying to run the bat file.
Error Milestone HSS 5/9/2011 3:06:46 PM LS0113 Task Sequence Manager 11170 The task sequence manager could not successfully complete
execution of the task sequence. A failure exit code of 16389 was returned.
Error Milestone HSS 5/9/2011 3:06:46 PM LS0113 Task Sequence Engine 11141 The task sequence execution engine failed execution of a
task sequence. The operating system reported error 1: Incorrect function.
Error Milestone HSS 5/9/2011 3:06:46 PM LS0113 Task Sequence Engine 11139 The task sequence execution engine aborted execution for
a failure of the action (Run Command Line) in the group (). The operating system reported error 1: Incorrect function.
Error Milestone HSS 5/9/2011 3:06:45 PM LS0113 Task Sequence Engine 11135 The task sequence execution engine failed executing the action
(Run Command Line) in the group () with the error code 1 Action output: =======================[ smsswd.exe ] ======================= PackageID = '' BaseVar = '', ContinueOnError='' SwdAction = '0001' Getting linked token Run command line
under a user account Command line for extension .bat is "%1" %* Set command line: Run command line Working dir 'not set' Executing command line: Run command line Create a process under given user token C:\Windows\system32>pushd C:\Windows\system32>C:\Quest\QuestAPlus.exe
/s /f1"C:\Windows\system32\setup.iss" Process completed with exit code 1 C:\Windows\system32>popd Command line returned 1. The operating system reported error 1: Incorrect function.
May 9th, 2011 5:22pm
Have you tried putting cmd.exe /c before the .bat file ? like this cmd.exe /c YourFile.bat ??
And if there is an .iss file associated with the .exe couldn't you just run C:\Quest\QuestAPlus.exe /s . The /s kind of implies a setup.iss being in the same directory!Michael Petersen http://blog.coretech.dk/mip/
Free Windows Admin Tool Kit Click here and download it now
May 9th, 2011 5:40pm
If there are no source files in the package, putting the package on the DP does not make sense and is not necessary. Delete the DP from the package and just advertise it.Jason | http://myitforum.com/cs2/blogs/jsandys | Twitter @JasonSandys
May 9th, 2011 6:15pm
Thanks Michael. That worked. I still get sccm reporting an error, but the batch runs and installs the software, so I can deal with an error.
Free Windows Admin Tool Kit Click here and download it now
May 10th, 2011 12:47pm