Announcement

Collapse
No announcement yet.

"If not" statement in bath script issue

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • "If not" statement in bath script issue

    Hi, There!!
    I need some help with the script I'm going to use as users logon script:

    Code:
    @echo off
    REM Set condition for server
    IF NOT /i %COMPUTERNAME% == LONDON GOTO NEXT
    REM Add printer
    rundll32 printui.dll,PrintUIEntry /in /n\\London\Xerox452M
    REM Set printer as default
    rundll32 printui.dll,PrintUIEntry /y /n\\London\\\Xerox45M
    So, the main idea is mapping some printer whenever user logging on to the clients except client with name London
    But in my case "If NOT" statement not worked at all and as result printer not mapped on any client PC's
    May be I'm missing something here...
    Any help will be appreciated!

  • #2
    I think you've got your logic a bit twisted. Your IF NOT command shouldn't have to call the next line, if there isn't any other code to differentiate it from. Normally, your 'GOTO NEXT' would infer that you have a ':NEXT' tag later in the file to jump to. In your case, you could change it to the following, adding double-quotes where appropriate as well:
    Echo off
    REM Set condition for server
    IF NOT "%COMPUTERNAME%" == "LONDON" (
    REM Add printer
    rundll32 printui.dll,PrintUIEntry /in /n\\London\Xerox452M
    REM Set printer as default
    rundll32 printui.dll,PrintUIEntry /y /n\\London\\\Xerox45M
    )
    Last edited by RicklesP; 19th August 2016, 19:50.
    *RicklesP*
    MSCA (2003/XP), Security+, CCNA

    ** Remember: credit where credit is due, and reputation points as appropriate **

    Comment


    • #3
      Thanks for your help! After correction is working as expected!!

      Comment


      • #4
        You're very welcome. Glad to know it worked.
        *RicklesP*
        MSCA (2003/XP), Security+, CCNA

        ** Remember: credit where credit is due, and reputation points as appropriate **

        Comment

        Working...
        X