Windows – Run a batch file from network shared folder depending on MS outlook bit version

batchbatch-filemicrosoft-officewindowswindows-command-prompt

Hello I'm trying to figure out on how to Run a file from network, basically it's located from \10.18.xx.xx\installers\install.bat, so yeah It's gonna prompt a username and password when I locate it manually.

What are the codes the I should use in bat file to run the install.bat from specific shared folder by determining on which version of MS outlook the computer has.
example: MS Outlook is 32bit version then it's gonna run the install.bat from 32bit folder, and for MS Outlook 64bit version then it's gonna run the install.bat from 64bit folder. TIA!

Sorry for stupid question, I'm new in batch commands..
Computers are using MS Outlook 2013. Anyway I tried to make this and run this bat file from desktop and it closes immediately after running it like nothing happened.

CheckOS
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)


:64BIT
\\10.18.xx.xx\Shared_Installers\PhishingOutlookPluginPH\64bit\install.bat -u 
myuser -p mypass
GOTO END



:32BIT
\\10.18.xx.xx\Shared_Installers\PhishingOutlookPluginPH\32bit\install.bat -u 
myuser -p mypass
GOTO END


:END

Best Answer

While debugging batch scripts, don't just launch them by clicking the icon, but from the command line (cmd.exe). Otherwise, you won't get to see the error messages. Now, for the actual problems...

  1. There could have been this error:

    UNC path are not supported. Defaulting to Windows directory.
    

    You can't refer to the share with an UNC path in .bat batch script. Options:

    • Rename you script as .cmd to enable UNC support.

    • Use pushd (and popd) to temporarily map a network drive, e.g.:

      pushd \\10.18.xx.xx\Shared_Installers\PhishingOutlookPluginPH\64bit\
      install.bat -u
      popd
      
  2. You can't enter username and password from a new line in the script! Options:

    • Map a network drive with net use and give the credentials as parameters. However, you won't have the advances of using pushd or UNC anymore, and you'll end up revealing the password in your script.

    • There's nothing secret on a share only containing software updates. (I believe your Shared_Installers is a share like that). Simply add read permissions to everyone and the problem is solved.

  3. Just a hint... With IF EXIST "%PROGRAMFILES(X86)%" you only check if the OS is 64bit. That can't tell you whether the Office installation is 64bit, too. In your environment that may always be true, but can't be generalized. Also, sometimes it's better to use x86 Office even on x64 OS.

    You could use the value of Bitness at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\XX.0\Outlook (the XX being the Office version) to determine the installed version. It should be easy to script if everyone has the same main version, and possible even if they don't.