tarinhtx Posted July 21, 2016 Report post Posted July 21, 2016 I have a batch file that if I run locally on a test computer it will correct a Skype for Business 2016 shortcut problem in the start menu by replacing the shortcut with a functional one with no problem. However, I'm having trouble deploying the batch file using as an Application through SCCM 2012 R2. The application deploys and "Installs" but for some reason the batch file never runs and completes the fix. Is there something I need to change on the line for the Installation Program: "filename.bat" under the Programs tab or maybe modify the batch file? Thanks. @ECHO OFF set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" del "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business 2016.lnk" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business 2016.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% echo oLink.TargetPath = "C:\Program Files\Microsoft Office\Office16\lync.exe" >> %SCRIPT% echo oLink.WorkingDirectory ="%SYSTEMDRIVE%\Program Files" >> %SCRIPT% echo oLink.Save >> %SCRIPT% cscript /nologo %SCRIPT% del %SCRIPT% Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted July 21, 2016 Report post Posted July 21, 2016 What make you think that the batch file isn't running? What security context are you running the batch file as, user or local system? Quote Share this post Link to post Share on other sites More sharing options...
tarinhtx Posted July 22, 2016 Report post Posted July 22, 2016 If I copy the batch file to the user's desktop and double click to execute, it completes the shortcut "fix" which deletes the nonworking SFB start menu shortcut and pastes the functioning SFB shortcut. So after the application is deployed hidden and shows up on the client's System Center as "Installed" under status, the batch file fix never took place. I placed the filename.bat file you see above in my content location \\servername\d$\Installs. Sorry, I'm not quite sure what you mean in your second question. Thanks for helping out. Quote Share this post Link to post Share on other sites More sharing options...
YPCC Posted July 22, 2016 Report post Posted July 22, 2016 That script does seem like the over complicated way of doing it. If i wanted to copy/update a shortcut i would simply take a copy of the functioning shortcut file (.LNK) and then just write a batch file to copy that shortcut into c:\programdata etc. Eg If exist "c:\programdata...\badshortcut.lnk" del "c:\programdata...\badshortcut.lnk" Copy "myshortcut.lnk" "c:\programadata......" /y Exit Then your application detection method will be to ensure the new shortcut exists. Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted July 22, 2016 Report post Posted July 22, 2016 If I copy the batch file to the user's desktop and double click to execute, it completes the shortcut "fix" which deletes the nonworking SFB start menu shortcut and pastes the functioning SFB shortcut. So after the application is deployed hidden and shows up on the client's System Center as "Installed" under status, the batch file fix never took place. I placed the filename.bat file you see above in my content location \\servername\d$\Installs. Sorry, I'm not quite sure what you mean in your second question. Thanks for helping out. Let me fix the typo above. Since CM uses the local system account to do just about everything, test your script using this process. https://verbalprocessor.com/2007/12/05/running-a-cmd-prompt-as-local-system/, When it works using this process it will work within CM too. Quote Share this post Link to post Share on other sites More sharing options...
tarinhtx Posted July 23, 2016 Report post Posted July 23, 2016 Garth, would I include: psexec -i -s cmd.exe into my batch file somewhere and change it to psexec -i -s batchfilename.bat? Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted July 23, 2016 Report post Posted July 23, 2016 You need to test your batch file using psexec -i -s batchfilename.bat command. This is how CM will run your batchfile. Quote Share this post Link to post Share on other sites More sharing options...
tarinhtx Posted July 23, 2016 Report post Posted July 23, 2016 I placed the command in the Installation Program line under the "Programs" tab. Deployed the application and as soon as it appeared in the Software it "Installed" but the batch file still failed to execute. Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted July 23, 2016 Report post Posted July 23, 2016 I placed the command in the Installation Program line under the "Programs" tab. Deployed the application and as soon as it appeared in the Software it "Installed" but the batch file still failed to execute. No that is not correct. You need to test your batch file using the PSexec to confirm that the batch file setup correctly. When you execute your batch file on your PC (or any other PC) does the batch file does what it should? My guess it that it will but for the LOCAL SYSTEM account. But that is not what you want, you want it for the locally logon user. Hence why you think that the batch file is failing when executed by CM. Once you confirm this step, you should be able to change the security context to the user security context and ultimately solve your problem. Quote Share this post Link to post Share on other sites More sharing options...
dinci5 Posted August 2, 2016 Report post Posted August 2, 2016 I placed the command in the Installation Program line under the "Programs" tab. Deployed the application and as soon as it appeared in the Software it "Installed" but the batch file still failed to execute. What is your detection method for this script? If your detection method is just the detection of the presence of this shortcut: "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Skype for Business 2016.lnk" Then your script will never run as this shortcut already exists (but is incorrect) so it will detect the presence and consider it successful without running it. So, what is your detection method to check whether the script ran succesfully? You can, for instance, create a reg key at the end of the script and use that as a detection method. Otherwise you could create a shortcut with a slightly different name (e.g. without 2016) and detect the presence of that one. Quote Share this post Link to post Share on other sites More sharing options...