Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

NEW How to silently deploy batch files that dont take arguments

  • Thread starter Thread starter yeps
  • Start date Start date
  • Replies Replies 7
  • Views Views 7K

yeps

Member
Messages
13
Solutions
2
Reaction score
0
Points
1
i have been tasked with pushing salesforce data loader to some devices via sccm. For some reason the company provides a batch file that i cannot figure out how to pass arguments to. I am unable to open a support case as I work on the IT side and do not have credentials to the website. Has anyone had luck deploying this tool silently? file is below for reference
Code:
@echo off
setlocal

set DATALOADER_VERSION=51.0.1
set DATALOADER_SHORT_VERSION=51
set DATALOADER_UBER_JAR_NAME=dataloader-51.0.1-uber.jar

echo.
echo *************************************************************************
echo **            ___  ____ ___ ____   _    ____ ____ ___  ____ ____       **
echo **            ^|  \ ^|__^|  ^|  ^|__^|   ^|    ^|  ^| ^|__^| ^|  \ ^|___ ^|__/       **
echo **            ^|__/ ^|  ^|  ^|  ^|  ^|   ^|___ ^|__^| ^|  ^| ^|__/ ^|___ ^|  \       **
echo **                                                                     **
echo **  Data Loader v%DATALOADER_SHORT_VERSION% is a Salesforce supported Open Source project to   **
echo **  help you import data to and export data from your Salesforce org.  **
echo **  It requires Zulu OpenJDK 11 to run.                                **
echo **                                                                     **
echo **  Github Project Url:                                                **
echo **       https://github.com/forcedotcom/dataloader                     **
echo **  Salesforce Documentation:                                          **
echo **       https://help.salesforce.com/articleView?id=data_loader.htm    **
echo **                                                                     **
echo *************************************************************************
echo.

echo Data Loader installation creates a folder in your '%USERPROFILE%' directory.
set /p DIR_NAME=Which folder should it use? [default: dataloader] || set DIR_NAME=dataloader

set INSTALLATION_DIR=%USERPROFILE%\%DIR_NAME%\v%DATALOADER_VERSION%

IF EXIST %INSTALLATION_DIR% (
    goto ExistingDir
) ELSE (
    goto CopyFiles
)

:ExistingDir
    echo.
    echo Do you want to overwrite previously installed versions of Data Loader v%DATALOADER_VERSION% and configurations in '%INSTALLATION_DIR%'?
    set /p DELETE_EXISTING_DIR=If not, installation will quit and you can restart installation using another directory.[Yes/No]
    if /I "%DELETE_EXISTING_DIR%"=="Y" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="Yes" goto DeleteDirYes
    if /I "%DELETE_EXISTING_DIR%"=="N" goto DeleteDirNo
    if /I "%DELETE_EXISTING_DIR%"=="No" goto DeleteDirNo
    echo Type Yes or No.
    goto ExistingDir
:DeleteDirYes
    echo Deleting existing Data Loader v%DATALOADER_VERSION%...
    rd /s /q %INSTALLATION_DIR%
    goto CopyFiles
:DeleteDirNo
    goto Exit

:CopyFiles
    echo.
    echo Copying files to '%INSTALLATION_DIR%'  ...
    xcopy . "%INSTALLATION_DIR%" /e /i
    del "%INSTALLATION_DIR%\install.bat" /q
    echo Your Data Loader v%DATALOADER_VERSION% is created in '%INSTALLATION_DIR%'

:CreateStartMenuShortCut
    echo.
    set /p REPLY=Would you like to create a start menu shortcut? [Yes/No]
    if /I "%REPLY%"=="Y" goto StartMenuShortCutYes
    if /I "%REPLY%"=="Yes" goto StartMenuShortCutYes
    if /I "%REPLY%"=="N" goto StartMenuShortCutNo
    if /I "%REPLY%"=="No" goto StartMenuShortCutNo
    echo Type Yes or No.
    goto CreateStartMenuShortCut
:StartMenuShortCutNo
    goto CreateDesktopShortcut
:StartMenuShortCutYes
    IF NOT EXIST "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\" (
        mkdir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce"
    )
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.Save()"
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Salesforce\Dataloader %DATALOADER_VERSION%.lnk" >nul

:CreateDesktopShortcut
    echo.
    set /p REPLY=Would you like to create a desktop icon? [Yes/No]
    if /I "%REPLY%"=="Y" goto StartMenuShortCutYes
    if /I "%REPLY%"=="Yes" goto StartMenuShortCutYes
    if /I "%REPLY%"=="N" goto StartMenuShortCutNo
    if /I "%REPLY%"=="No" goto StartMenuShortCutNo
    echo Type Yes or No.
    goto CreateDesktopShortcut
:StartMenuShortCutNo
    goto Exit
:StartMenuShortCutYes
    powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut(""""$Home\Desktop\Dataloader.lnk""""); $Shortcut.WorkingDirectory = """"$env:INSTALLATION_DIR""""; $Shortcut.TargetPath = """"$env:INSTALLATION_DIR\dataloader.bat""""; $Shortcut.IconLocation = """"$env:INSTALLATION_DIR\dataloader.ico""""; $Shortcut.Save()"
    move "%USERPROFILE%\Desktop\Dataloader.lnk" "%USERPROFILE%\Desktop\Dataloader %DATALOADER_VERSION%.lnk" >nul

:Exit
    echo.
    echo Data Loader installation is quitting.
    endlocal
    PAUSE
 
There are no trick to this, just add the commandline to the CM program install.
 
There are no trick to this, just add the commandline to the CM program install.
hey garth thanks for the quick reply. would you be able to expand on this? are you suggesting just having the users run through the gui when they install from software center? the program itself does not seem to accept and kind of command line parameters
 
hey garth thanks for the quick reply. would you be able to expand on this? are you suggesting just having the users run through the gui when they install from software center? the program itself does not seem to accept and kind of command line parameters
I'm not sure what you are look for as there are no tricks for CM to deploy something. Does the batch file work outside of CM? this is the first thing to look at? Then answer, exactly what are you using within CM to deploy this?
 
I'm not sure what you are look for as there are no tricks for CM to deploy something. Does the batch file work outside of CM? this is the first thing to look at? Then answer, exactly what are you using within CM to deploy this?
it does work outside of cm by calling the install.bat file. the batch file is actually just an application, but it does not call an .exe or .msi. i was thinking i could just package this up as a normal application in sccm but now realize that may not be the best way to go about it
 
What EXACTLY is your goal? "install" it locally and create a shortcut to the batch file?
 
What EXACTLY is your goal? "install" it locally and create a shortcut to the batch file?
install it silently on a large scale, without any user interaction. there are 3 prompts, one where to install and two yes no questions, where to make a shortcut on desktop and start page. there is no native way to silent the install. i realize sccm cannot do this itself but did not know if it could be done by another script
 
install it silently on a large scale, without any user interaction. there are 3 prompts, one where to install and two yes no questions, where to make a shortcut on desktop and start page. there is no native way to silent the install. i realize sccm cannot do this itself but did not know if it could be done by another script
yes it can be done by another script but you will need to write it for ask the author to provider you with a "setup". A "setup" can be a batch file, MSI, exe, powershell, vbs, etc. but the content have to end up on the local computer and CM will not magically do that. It will run a "setup" then the uses will click an icon or ??? to launch this app.
 
Back
Top