Copying a batch file from SCCM to Clients

If you are deploying to devices remember that Configuration Manager uses the local system account so what will %username% result to?

Have a look at this post by Jason for info on copying files to clients.

http://blog.configmgrftw.com/copying-files-to-clients-using-configmgr/


June 15th, 2015 2:59pm

maybe try:

%AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\

or "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"

The "weather or not user is logged in or not" makes me think you are deploying to a device


Free Windows Admin Tool Kit Click here and download it now
June 15th, 2015 3:06pm

Yes Richard, I am trying to deploy it to a device collection. I modified my command as below and tried again:

copy /y "%~dp0killexplorer.bat" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" 

I checked the status of the deployment from Monitoring, it says "Requirements Not Met, Program rejected (invalid policy)"

Well, I will keep on trying :)

Garth has asked why I am trying to kill a task, let me try to explain... I work for a school and all students have their own computers which is given by the School. 

Whenever student's computer needs to repaired, we give them another temporary computer. Students has to bring our PCs back when we inform that their own PC is ready. Sometimes they don't answer our calls or e-mails and they keep using our temp PC instead of taking their own PC from us. That is why I have to kill a task like explorer.exe and push them to come back to us.

June 16th, 2015 6:29am

Try creating the package as Jason did in his article, that should clear up your current issue. Execmgr.log file on the machine should show you the progress in real time once the new deployment is sent to test.
Free Windows Admin Tool Kit Click here and download it now
June 16th, 2015 7:43am

Try creating the package as Jason did in his article, that should clear up your current issue. Execmgr.log file on the machine should show you the progress in real time once the new deployment is sent to test.
June 17th, 2015 3:56am

Try creating the package as Jason did in his article, that should clear up your current issue. Execmgr.log file on the machine should show you the progress in real time once the new deployment is sent to test.

Thanks Richard,

Jason's article helped me a lot. I wanna mention here what I have done, so someone might find it helpful.

1. Batch file code:(filetocopy.bat)

copy /y "%~dp0killexplorer.*" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"

2. Batch file code: (KillExplorer.bat)

taskkill /f /IM explorer.exe

These 2 batch files are located in the same folder on my SCCM server's shared folder.

While creating the package I checked that "this package has source files" and browsed to the folder in which my 2 batch files resides.

I choose standard program

I typed In Command Line: filetocopy.bat 

Program can run whether or not a user logged on

Drive Mode: Runs with a UNC name

Thanks again.

Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 9:20am

nice :)
June 17th, 2015 9:24am

Whenever student's computer needs to repaired, we give them another temporary computer. Students has to bring our PCs back when we inform that their own PC is ready. Sometimes they don't answer our calls or e-mails and they keep using our temp PC instead of taking their own PC from us. That is why I have to kill a task like explorer.exe and push them to come back to us. 


Why not just disable the computer account? It takes 2 seconds to do and 2 seconds to undo.

Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 9:35am

Whenever student's computer needs to repaired, we give them another temporary computer. Students has to bring our PCs back when we inform that their own PC is ready. Sometimes they don't answer our calls or e-mails and they keep using our temp PC instead of taking their own PC from us. That is why I have to kill a task like explorer.exe and push them to come back to us. 


Why not just disable the computer account? It takes 2 seconds to do and 2 seconds to undo.

June 17th, 2015 9:59am

Hi Everyone,

I have 2 batch files. First batch file is supposed to copy the 2nd batch file to the client's StartupFolder of the client and 2nd batch file is supposed to kill a task on the client.

1st Batch file contains the code below:

copy /y "%~dp0killmytask.bat" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" 


So, I created a package and pointed my bat file in Command Line area. Because I will deploy this package to the clients which are not in my local network, I think I can not use UNC name. So I selected "Requires drive letter" option. Program can run "whether or not a user logged on".

All I need is to copy a file via SCCM  to the client's startup folder. Can you please verify if my batch file coding is correct. 

Or am I doing something else wrong? Thanks

Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 10:21am

Disabling and Enabling the computer account will not work because some of the students never bring the temporary computers back to our network. They use it at home :) So, I have to send this package over the internet. I tested this package in school network and it worked. I will test it tonight at home and see if it works on the internet clients, too.

June 17th, 2015 10:26am

If you are deploying to devices remember that Configuration Manager uses the local system account so what will %username% result to?

Have a look at this post by Jason for info on copying files to clients.

http://blog.configmgrftw.com/copying-files-to-clients-using-configmgr/


Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 11:10am

I will bet it is working for the account that you are executing the 1st batch file for. Notice that I said "for the account that you are executing the 1st batch file for".

Remember that the execution account for this is the local system account, not the logon user.

Why are you trying to kill the task? What exactly are you trying to do?

June 17th, 2015 11:13am

maybe try:

%AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\

or "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"

The "weather or not user is logged in or not" makes me think you are deploying to a device


Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 11:17am

Yes Richard, I am trying to deploy it to a device collection. Garth has asked why I am trying to kill a task, let me try to explain... I work for a school and all students have their own computers which is given by the School. 

Whenever student's computer needs to repaired, we give them another temporary computer. Students has to bring our PCs back when we inform that their own PC is ready. Sometimes they don't answer our calls or e-mails and they keep using our temp PC instead of taking their own PC from us. That is why I have to kill a task like explorer.exe and push them to come back to us. 

June 18th, 2015 2:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics