0

Hi I currently have a working script with some simple logic to it. I'd like to add this type of line in 4 places on the script so we can kind of track if a user ran the script or not and which part of the script was or wasn't ran.

The working script with out the logging is this:

@echo off
if exist "C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login Client\Newtonsoft.Json.xml" GOTO ENDSCRIPT 
If exist "C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login Client\FiddlerCore4.dll" (Call "C:\Program Files (x86)\InstallShield Installation Information\{3E1***35-24F9-49D9-9A39-F310D8C25A6E}\setup.exe"/uninstall) ELSE (call \\******.com\files\it\packages\Intellichief4\ICsetup\setup.exe /silent -Env ic01system.*******.com 10800 -WB -PR) 

I'd like to add Lines like this to the script in all 3 actions.

The script first checks if v.4 of the application is installed, if it is it ends the script. Then the script sees if v.3 of the application is installed and if it is it runs an uninstallation or if application is not installed it will install v.4 of the application and end.

I'd like to add this line 3 times :

1 for "Application is already installed" 1 for "Uninstalling Application" 1 for "Installing v.4 of Application"

This script will have to be ran twice by people with the old version so that they can get it uninstalled, reboot and then click it again to start the installation of the new version.

ECHO "IntelliChief v.4 is already installed" >> "\\******.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAME%_%USERNAME%.txt"

This is how I tried to make the script but it took the first script that is working and broke it. I failed. :(

@ECHO OFF
if exist ("C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login 
Client\Newtonsoft.Json.xml"); THEN 
ECHO "IntelliChief v.4 is already installed" >> 

\bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNA ME%%USERNAME%.txt GOTO ENDSCRIPT If exist ("C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login Client\FiddlerCore4.dll"); THEN (Call "C:\Program Files (x86)\InstallShield Installation Information\ {3E189F35-24F9-49D9-9A39-F310D8C25A6E}\setup.exe"/uninstall) ECHO "Uninstalling IntelliChief v.3" >> \bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAM E%%USERNAME%.txt ELSE (call \bakertanks.com\files\it\packages\Intellichief4\ICsetup\setup.exe /silent -Env ic01system.bakertanks.com 10800 -WB -PR); THEN ECHO "Installing IntelliChief v.4" >> \bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAM E%_%USERNAME%.txt

:ENDSCRIPT

I can't seem to get the format to work with UNC paths, it won't let me do four spaces.

4
  • 2
    Okay. What's your question? Commented Aug 31, 2017 at 21:24
  • When I add the ECHO/log lines my script goes to south on me. :( I'd be able to give you examples of what I tried when I get back in to the office tomorrow morning. I'd like to add the ECHO line to all 3 actions so that it writes a file to a network folder that is titled COMPUTERNAME_USERNAME, inside the file would be the lines that were ECHO'ed so I know which step the users are one for possible troubleshooting and visibility. Commented Aug 31, 2017 at 23:08
  • The formatting makes it very difficult to read. What happens when you add the logging and run your script? What error message do you get? Commented Sep 1, 2017 at 13:39
  • It's very had to be sure, because you've not formatted it well, but it looks like you've got the echo commands outside the parentheses of the if ... ( ... ) else ( ... ) statements: i.e. if ... ( ... ) echo something else ( ... ) They need to be inside the parentheses. (And probably split onto multiple lines for clarity). Commented Sep 1, 2017 at 14:11

1 Answer 1

1

I used your script that you said worked and added some ECHO lines for logging. I think this will do what you want:

@ECHO OFF
IF EXIST "C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login Client\Newtonsoft.Json.xml" (
  ECHO "IntelliChief v.4 is already installed" >>\\bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAME%_%USERNAME%.txt
  GOTO ENDSCRIPT
)

IF EXIST "C:\Program Files (x86)\IntelliChief\IntelliChief Clients\Login Client\FiddlerCore4.dll" (
  CALL "C:\Program Files (x86)\InstallShield Installation Information\{3E1***35-24F9-49D9-9A39-F310D8C25A6E}\setup.exe" /uninstall
  ECHO "Uninstalling IntelliChief v.3" >>\\bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAME%_%USERNAME%.txt
) ELSE (
  CALL \\******.com\files\it\packages\Intellichief4\ICsetup\setup.exe /silent -Env ic01system.*******.com 10800 -WB -PR
  ECHO "Installing IntelliChief v.4" >>\\bakertanks.com\files\Diagnostics\Logon\Workstations\IntelliChief4\%COMPUTERNAME%_%USERNAME%.txt
)

:ENDSCRIPT
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.