locked
How can I deploy a simple bat file using sccm2012? RRS feed

  • Question

  • Hello,

    I am just trying to deploy a simple batch file to remove some old VPN connection, but even after several attempts and google. not able to achieve it via SCCM 2012.

    I have tried the following steps: 

    1: Software Library -> Application Management -> create a new Package with nothing in source file, new program and batch file location in "commandline"
    selected option use drive letter

    2: deploy - right click on new pakage and deploy to required collection.

    but Keep getting following error:

    Program rejected (invalid policy)

    Failed (bad enviornment)

    Please help.

    Thanks


    • Edited by Beadmin Wednesday, December 11, 2013 9:27 AM info add
    Wednesday, December 11, 2013 9:26 AM

Answers

  • If you don't include source files in the package, then the agent can't find or access your batch file as it has no idea where to access it from/at.

    For reference error code 2 (0x80070002 is an HRESULT where the last four digits specify the actual error code) is a file not found error.

    Also, there's no explicit need to specify "requires drive letter" -- it doesn't necessarily hurt in this case, but doesn't help either.


    Jason | http://blog.configmgrftw.com

    • Proposed as answer by Joyce L Thursday, December 12, 2013 2:35 AM
    • Marked as answer by Joyce L Monday, December 30, 2013 6:42 AM
    Wednesday, December 11, 2013 2:31 PM
  • To deploy software, or a batch file is pretty much the same deal, considering SCCM.

    I'd create a package containing your file, and create a program running it. Remember to distribute it to your distribution point, and from there deploy it to your collection.


    Martin Bengtsson | www.imab.dk

    • Proposed as answer by Joyce L Wednesday, December 18, 2013 9:42 AM
    • Marked as answer by Joyce L Monday, December 30, 2013 6:42 AM
    Thursday, December 12, 2013 8:23 AM

All replies

  • You would normally get this when the program could not be run because the policy contains an invalid combination of
    requirements

    eg :

    1. The program is set to run when no user is logged on, but has been deployed to a user.

    2. The program is set to require user input, but does not require that a user be logged on in order to run.

    What batch file are you trying to run and how are you deploying it?



    Gerry Hampson | Blog: www.gerryhampsoncm.blogspot.ie | LinkedIn: Gerry Hampson | Twitter: @gerryhampson

    Wednesday, December 11, 2013 9:34 AM
  • I am running this batch file, I changed the option back to "run when user is logged" one but still failed:

    @echo off
    c:
    cd\
    rasphone -r "VPN1"
    c:
    cd\
    rasphone -r "VPN2"


    exit 0

    Error on the client machine; Failed : Error: 0x80070002(-2147024894)

    • Edited by Beadmin Wednesday, December 11, 2013 10:12 AM info add
    Wednesday, December 11, 2013 10:05 AM
  • Have you checked "This package contains source file" when creating the package? How does the command line of the package prgram looks like?
    Wednesday, December 11, 2013 10:13 AM
  • No, I left it unchecked.

    please see this:(also tried selecting run as admin)


    • Edited by Beadmin Wednesday, December 11, 2013 1:35 PM info
    Wednesday, December 11, 2013 1:34 PM
  • If you don't include source files in the package, then the agent can't find or access your batch file as it has no idea where to access it from/at.

    For reference error code 2 (0x80070002 is an HRESULT where the last four digits specify the actual error code) is a file not found error.

    Also, there's no explicit need to specify "requires drive letter" -- it doesn't necessarily hurt in this case, but doesn't help either.


    Jason | http://blog.configmgrftw.com

    • Proposed as answer by Joyce L Thursday, December 12, 2013 2:35 AM
    • Marked as answer by Joyce L Monday, December 30, 2013 6:42 AM
    Wednesday, December 11, 2013 2:31 PM
  • Thanks for the reply Jason.

    If I dont want to deploy a software and just a bat, is that not possible with SCCM

    Thursday, December 12, 2013 7:24 AM
  • To deploy software, or a batch file is pretty much the same deal, considering SCCM.

    I'd create a package containing your file, and create a program running it. Remember to distribute it to your distribution point, and from there deploy it to your collection.


    Martin Bengtsson | www.imab.dk

    • Proposed as answer by Joyce L Wednesday, December 18, 2013 9:42 AM
    • Marked as answer by Joyce L Monday, December 30, 2013 6:42 AM
    Thursday, December 12, 2013 8:23 AM
  • For execute .bat, is necessary set other user
    Friday, December 28, 2018 4:20 PM
  • no it is not necessary to include another user account to execute a batch or cmd command. you only require this when you are trying to access files from across the network, when it is preferred to have those files within the package.

    Garth Jones

    Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/

    Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed

    Friday, December 28, 2018 4:27 PM
  • If your package contains all the files necessary, do you still need to have a user account?  Shouldn't it just download them and run the bat?  I ask because I can't get my batch files to run via deployment with a similar message ID 10052 (requirements not met, invalid policy).
    Wednesday, April 24, 2019 8:28 PM
  • No. As Garth notes, that's simply the account used to run the command-line that you've supplied.

    Can you please post your smsts.log (on a file sharing service and link to it here)?


    Jason | https://home.configmgrftw.com | @jasonsandys

    Wednesday, April 24, 2019 8:52 PM
  • It's not in a TS, it's just a package deployment, and I can try to find what logs to provide, but maybe you could point me in the right direction (path) for those?   Cause I'm pretty new to this and despite reading about log locations several times, finding the right logs is always an arduous task.
    Thursday, April 25, 2019 1:29 PM
  • It's not in a TS, it's just a package deployment, and I can try to find what logs to provide, but maybe you could point me in the right direction (path) for those?   Cause I'm pretty new to this and despite reading about log locations several times, finding the right logs is always an arduous task.

    here is a list of log files, what they do and where they are found.

    https://docs.microsoft.com/en-us/sccm/core/plan-design/hierarchy/log-files

     


    Garth Jones

    Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/

    Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed

    Thursday, April 25, 2019 2:44 PM
  • Then what exactly are you talking about as there is no way to specify an alternate account for packages? The screenshot above that you replied to is from a task sequence and is the only way to supply alternate credentials. If you are asking about something unrelated to this thread, you really should start a new thread.

    Jason | https://home.configmgrftw.com | @jasonsandys

    Thursday, April 25, 2019 3:31 PM
  • I did. But wanted input from those who have actually provided advice in the past since my issue is similar.  Don't worry about it. Thanks.
    Thursday, April 25, 2019 5:30 PM
  • Thank you, are there sccm server logs that would give info about deployment messages/failures? I read that the logs I want to look at are on the client, but sometimes that isn't convenient.

    Friday, April 26, 2019 8:26 PM