Trying to run this .bat via SCCM

Viewed 218

I am trying to deploy an application through a .bat via SCCM. The .bat executes perfectly when I run it on my local workstation via CMD. When I deploy it and try to install it via Software Center, it says it can't find the .exe. How do I specify it should look in the same directory location as the .bat file?

Here's what I've written up:

@echo off

REM Install VooV
start VooVMeeting.exe /S

REM Create Shortcut
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "C:\Users\%USERNAME%\Desktop\VooV Meeting.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "C:\Program Files (x86)\Tencent\VooVMeeting\voovmeetingapp_new.exe" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%

cscript /nologo %SCRIPT%
del %SCRIPT%

REM Sleep Script
timeout /t 30 /nobreak>NUL

REM Send Exit Code
EXIT /B 0

I feel like this is a simple fix but I am too stupid to figure it out. Thanks for any pointers.

1 Answers

When using .bat or .cmd files from SCCM/MECM, which I almost never do now with a custom template for Powershell App Deployment Toolkit, pushd "%~dp0" is a winner.

Start the .bat with

@echo off
pushd %~dp0

As previously said in comments, add "" or "your window title" to start command, and add /wait to fix any detection error after installation

start "VooV installation" /wait VooVMeeting.exe /S

With SCCM/MECM installations, I would also send the shortcut to "%ALLUSERSPROFILE%\Desktop\VooV Meeting.lnk" or better objShell.SpecialFolders("AllUsersDesktop") or Startmenu objShell.SpecialFolders("AllUsersPrograms"). %USERNAME% will not create the shortcut in a folder for the user to see, but SYSTEM profile or an account for SCCM.

Related