"If not" statement in bath script issue

Home Forums Scripting DOS Command Shell "If not" statement in bath script issue

This topic contains 3 replies, has 2 voices, and was last updated by Avatar Anonymous 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • Avatar
    igor7
    Member
    #166555

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

    @echo off
    REM Set condition for server
    IF NOT /i %COMPUTERNAME% == LONDON GOTO NEXT
    REM Add printer
    rundll32 printui.dll,PrintUIEntry /in /n\LondonXerox452M
    REM Set printer as default
    rundll32 printui.dll,PrintUIEntry /y /n\London\Xerox45M[/CODE]

    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!
    [CODE]@echo off
    REM Set condition for server
    IF NOT /i %COMPUTERNAME% == LONDON GOTO NEXT
    REM Add printer
    rundll32 printui.dll,PrintUIEntry /in /n\LondonXerox452M
    REM Set printer as default
    rundll32 printui.dll,PrintUIEntry /y /n\London\Xerox45M[/CODE]

    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!

    Avatar
    Anonymous
    #371950

    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:
    [USER=”68995″]Echo[/USER] off
    REM Set condition for server
    IF NOT “%COMPUTERNAME%” == “LONDON” (
    REM Add printer
    rundll32 printui.dll,PrintUIEntry /in /n\LondonXerox452M
    REM Set printer as default
    rundll32 printui.dll,PrintUIEntry /y /n\London\Xerox45M
    )

    Avatar
    igor7
    Member
    #295082

    Thanks for your help! After correction is working as expected!!

    Avatar
    Anonymous
    #371954

    You’re very welcome. Glad to know it worked.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.