+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, Script help in Coding and Web Development; I'm trying to create a batch script to push out 2 MSI packages. I've got the install part of the ...
  1. #1

    Join Date
    Nov 2009
    Posts
    43
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script help

    I'm trying to create a batch script to push out 2 MSI packages. I've got the install part of the script written, but the third character of our computer naming scheme indicates whether or not I want the install to proceed. Anyone know how to read the 3rd character of the %computername% variable?

  2. #2

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    Checks if the third letter (2=you count from 0, 1 = length) is "7":

    set letter3=%computername:~2,1%
    if "%letter3%" equ "7" (
    rem do all your installing in here
    )

  3. #3

    Join Date
    Nov 2009
    Posts
    43
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script help

    This is what I have so far. It's still going through the install process when the if condition is not satisfied.

    set letter3=%computername:~2,1%
    if %letter3% equ "T" goto loadsoft

    echo PC not need update
    exit
    pause

    :loadsoft
    msiexec /i "\\uufsd\district\pushed\district\activinspire\dri ver.msi" /qn
    msiexec /i "\\uufsd\district\pushed\district\activinspire\act ivinspire.msi" /qn

  4. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    the "if" statement defaults to being case sensitive and you either don't need the quotes around the "T" or you need them around the variable as well and not sure about using "equ" - I use ==

    if /i "%letter3%" == "T" goto loadsoft

    (the "" bit is essential if the variable might not be set; it can actually be anything, it's just to make sure that you don't end up with a blank on the left hand side of the test)
    Last edited by srochford; 23rd July 2010 at 01:33 PM.

  5. #5

    Join Date
    Nov 2009
    Posts
    43
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I added the /i switch to the if statement and it is not skipping to the loadsoft section if the condition is met. I just tested on a PC where the condition is met, and it just ran through the beginning and it tells me that the PC doesn't get the update (which is just there for testing purposes).

  6. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    have you also changed the quotes - it won't work as you have it because what you're doing is testing if T is equal to "T" which it isn't!

    Just make a really simple test file:
    Code:
    @echo off
    set letter3=%computername:~2,1%
    if "%letter3%" == "T" echo "going to install"
    - on a machine where you want it to work it should say "going to install"; other machines should do nothing.

  7. #7

    Join Date
    Nov 2009
    Posts
    43
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I removed the quotation marks around the T and it worked the way I want it to.

SHARE:
+ Post New Thread

Similar Threads

  1. Script
    By Ryno in forum Web Development
    Replies: 6
    Last Post: 13th April 2010, 09:09 PM
  2. Need a Script if Possible
    By Paul_L in forum Scripts
    Replies: 6
    Last Post: 2nd October 2008, 02:33 PM
  3. Best script ever!
    By Zabu in forum Scripts
    Replies: 0
    Last Post: 6th November 2007, 11:48 PM
  4. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  5. Does anyone have a script...
    By wesleyw in forum Scripts
    Replies: 4
    Last Post: 5th July 2007, 01:58 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •