[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5826
  • Last Modified:

running a batch file using sccm

we are trying to run a windows batch file using sccm. the script looks like this

@ECHO OFF
cd\
md tools
cd tools
xcopy \\computer name\folder\tools\*.* c:\tools
pskill - accepteula wfica32.exe
pskill  -a accepteula wfcrun32.exe
sleep 10
msg * /time:50 "Citrix ICA client upgrade in progress,please do not open any Citrix Application till this message box is displayed. Thank you, ITA"
start "" \ \\computer name\folder\webcustom.msi

when this script runs, it creates a folder called tools, then does not copy the files to the local computer and does not run ths msi file also. if you run the script directly it works fine. we are not deploying the .msi file directly as we want to kill the process before the msi runs. whats going wrong. a normal xcopy does not copy the files, it does display the message from the script and also does not run the msi. need help
0
mgmohiuddin
Asked:
mgmohiuddin
4 Solutions
 
Rem-8Commented:
You should see the user, who runs the script, as appropriate priviledges. It looks like your batch is missing some priviledges. You can also simply run MSI and in the app sequence run an additional script.
0
 
mgmohiuddinAuthor Commented:
could you give me more details please. i am not an sccm expert. i thought so but i am deploying it through sccm so uses an admin account right.  i basically want to  kill some processes, display a message informing the users that an upgrade is being performed and not to use the client for some time. lastly need to run the msi. so can we do it in a sequence.

like when you are advertising the program there is an option to run a command befor the deployment. can i write a batch file to kill the processes as part of the batch file and the same batch file displays a message. can you please give me more details
0
 
mgmohiuddinAuthor Commented:
there should not be a delay between the time the the process is killed and the msi runs as in the mean time if the user starts the application the process starts again and the upgrade could fail. so are you  trying to say i will deploy an msi and add a script to kill the processes as part of the batch file. need more info please
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Adam LeinssCommented:
SCCM is a poor solution for updating things that could be in use by the user or are time sensitive.  You're better off deploying the MSI using Group Policy which applies the package before user can login or use the WOL capabilties of SCCM and setup maintainence window for an after hours installation.
Also, the "sleep" command is not native to Windows, unless that's part of your standard PC image, neither is pskill.  You probably would want to use taskkill over pskill since pskill is for terminating processes on remote boxes (you're running it locally, not remotely). By default, all files in your package get copied down to the PC it's advertised to unless you pick "Run from distribution point".  So you could just add the "sleep" and "pskill" files to your package and then you don't have to worry about copying them from the DP.
0
 
JonLambertCommented:
Also, make sure that your SCCM advert is set to download and execute (i.e. not run from DP), make sure your SCCM program starts looks like "CMD /C BatchFile.bat", and if you want to run the program when no one is logged on, make sure that the program Environment is set to Run as an Administrator, and only run "When no user is logged on"

You will also need to ensure that your \\computername\folder share is set to allow domain computers to read, as well as the NTFS permissions in the folder targeted by the share.  When you run an SCCM program as an Administrator, unless you specify to use the Network Access Account, the computer account will be used to execute the program.
0
 
HerrmannatorCommented:
On the same track as what JonLambert suggested, but to simplify even further, you might want to try to put your entire package into a folder on the distribution point, then have the advertisement set to download this folder locally to the machine and execute it locally (under admin privlages).  Under this approach you'd stay away from pointing at UNC paths, and instead download everything local.  This way you can easily test by copying this folder to the C drive of a test machine, logging in as local admin, and making sure running the batch file does what you need.  If so, it should work when SCCM tries to do the same.  Also if you set the advertisement to run at logon, you may be able to avoid the need for killing the processes, but either way would be OK on that.
0
 
Justin_W_ChandlerCommented:
You are very close in accomplishing your goal, based on the script you posted. There are a few changes however. Please see below for an explanation, and in the code box is just the code without all the comments


@echo off

::Create the tools folder, and a temporary folder to hold your MSI file
mkdir c:\tools
mkdir c:\tmpinstl
copy /y \\COMPUTERNAME\FOLDER\TOOLS\*.* c:\tools
copy /y \\COMPUTERNAME\FOLDER\WEBCUSTOM.MSI c:\tmpinstl

::PSKill equivalent from Microsoft (PSKill will work but you may not have it on all computers in the domain)
taskkill /im wfica32.exe /f
taskkill /im wfcrun32.exe /f

::Simple way to delay 10 seconds without relying on the sleep command
ping 127.0.0.1 -n 10 > nul

::You're missing an assignment of who to make the message to. Just use an asterik to indicate all logged on sessions.
msg * /time:50 "Citrix ICA client upgrade in progress,please do not open any Citrix Application till this message box is displayed. Thank you, ITA"

::Though you can start remote processes locally on a machine, it's incredibly slow compared to this solution, which copies the installer locally and executes it here. It's easier on the server, and faster on the workstation.
start "" /wait c:\tmpinstl\webcustom.msi

::Delete the temporary directory
rmdir /s /q c:\tmpinstl


I hope this helps,
Justin Chandler


@echo off
mkdir c:\tools
mkdir c:\tmpinstl
copy /y \\COMPUTERNAME\FOLDER\TOOLS\*.* c:\tools
copy /y \\COMPUTERNAME\FOLDER\WEBCUSTOM.MSI c:\tmpinstl
taskkill /im wfica32.exe /f
taskkill /im wfcrun32.exe /f
ping 127.0.0.1 -n 10 > nul
msg * /time:50 "Citrix ICA client upgrade in progress,please do not open any Citrix Application till this message box is displayed. Thank you, ITA"
start "" /wait c:\tmpinstl\webcustom.msi
rmdir /s /q c:\tmpinstl
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now