Windows 7 Dont run script IF

Discussion in 'Programming and Scripting' started by Orinoco74, Dec 4, 2013.

  1. Orinoco74

    Orinoco74 New Member

    Joined:
    Dec 4, 2013
    Messages:
    1
    Likes Received:
    0
    I have an issue, i have just started a Windows 7 Migration Project and i was originally brought in to do GPO, now i have bene asked to do something else and i am a little stuck. Basically we still run Windows XP on most of our machines but will start migrating over to 7 soon. We run a batch script that is set up as part of the users profile in AD and runs in XP only. For Windows 7, icons and shortcuts are all done via GPO.

    What i want to do is run this batch script but ONLY if the pc is running Windows XP. If the pc is running Windows 7, i want the script to quit and not do anything and let GPO do its thing. Here is the script if anyone can help. (some has been changed to protect identity of company). Thank you in advance

    @echo OFF
    REM LAST CHANGE - 18th July 2013
    REM To Remove update xxx & Emplyee Onlinee Shortcuts
    REM
    REM
    REM IF YOU CHANGE THIS FILE, PLEASE COPY THE ORIGINAL INTO OLDLOGONBAT FOLDER AND
    REM RENAME IT WITH THE DATE IT WAS LAST USED.
    REM
    REM THEN CHANGE THE FIRST TWO REM LINES ABOVE TO THE DATE OF THE CHANGE AND
    REM WHAT YOU HAVE CHANGED
    REM
    REM THANKS
    REM
    CLS
    TITLE xxx Logon Script
    Echo Welcome to the xxx domain. Please wait while your logon is processed...
    Echo.

    REM ---- MAPS A U AND V DRIVE TO CENTRAL SHARE ---
    net use u: /delete /YES
    net use u: \\fileserver1\shares
    net use v: /delete /YES
    net use v: \\fileserver2\shares
    net use x: /delete /YES
    net use x: \\fileserver3a\shares
    REM --- MAPS p DRIVE FOR Programme Team
    %LOGONSERVER%\netlogon\tools\ifmember.exe "xxx"
    if errorlevel 1 goto mapptpdrive
    goto skipptpdrive
    :mapptpdrive
    net use p: /delete /YES
    net use p: \\fileserver3a\HFTProg$
    :skipptpdrive
    REM --- MAPS t DRIVE FOR Training Folder
    %LOGONSERVER%\netlogon\tools\ifmember.exe "HFT_TrainingArea"
    if errorlevel 1 goto maptftdrive
    goto skiptftdrive
    :maptftdrive
    net use t: /delete /YES
    net use t: \\fileserver3a\TrainingArea$
    :skiptftdrive
    %LOGONSERVER%\netlogon\tools\ifmember.exe "HFT_TrainingArea"
    if errorlevel 1 goto insttticons
    goto skipinsttticons
    :insttticons
    IF EXIST "C:\PROGRAM FILES\LORENZOSHORTCUTS\LORENZO.ICO" GOTO QUITTTICONS
    CD "C:\PROGRAM FILES"
    IF NOT EXIST LORENZOSHORTCUTS MD LORENZOSHORTCUTS
    CD LORENZOSHORTCUTS
    copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LORENZOSHORTCUTS\LORENZO.ICO" "C:\PROGRAM FILES\LORENZOSHORTCUTS"
    :QUITTTICONS
    IF EXIST "C:\PROGRAM FILES\LORENZOSHORTCUTS\HEALTHROSTER.ICO" GOTO QUITHRICONS
    CD "C:\PROGRAM FILES"
    copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxx\HealthRoster.ico" "C:\PROGRAM FILES\LORENZOSHORTCUTS"
    :QUITHRICONS
    if exist "C:\Documents and Settings\All Users\Desktop\New LSP Portal.url" del "C:\Documents and Settings\All Users\Desktop\New LSP Portal.url"
    if exist "%userprofile%\Desktop\New LSP Portal.url" del "%userprofile%\desktop\New LSP Portal.url"
    if exist "%userprofile%\Desktop\New Lorenzo on 671.lnk" del "%userprofile%\desktop\New Lorenzo on 671.lnk"
    if exist "%userprofile%\Desktop\Lorenzo Training.url" del "%userprofile%\desktop\Lorenzo Training.url"
    if exist "%userprofile%\Desktop\Lorenzo on TRGLOR528 (Training).lnk" del "%userprofile%\desktop\Lorenzo on TRGLOR528 (Training).lnk"
    if exist "%userprofile%\Desktop\New Lorenzo TRG.url" del "%userprofile%\desktop\New Lorenzo TRG.url"
    if exist "%userprofile%\desktop\Lorenzo Training (TRGLOR528).lnk" del "%userprofile%\desktop\Lorenzo Training (TRGLOR528).lnk"
    if not exist "%userprofile%\desktop\Lorenzo Training (TRGLOR671).lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LorenzoShortcuts\Lorenzo Training (TRGLOR671).lnk" "%userprofile%\desktop"
    if not exist "%userprofile%\desktop\New LSP Portal (Read Only).url" copy /Y "%LOGONSERVER%\netlogon\icons\xxxx\LorenzoShortcuts\New LSP Portal (Read Only).url" "%userprofile%\desktop"
    if not exist "%userprofile%\desktop\Lorenzo 1006 Day Care.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LorenzoShortcuts\Lorenzo 1006 Day Care.lnk" "%userprofile%\desktop"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\SandPit.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxx\SandPit.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"
    if exist "%userprofile%\desktop\eRostering Training\" rd /s /q "%userprofile%\desktop\eRostering Training"
    :skipinsttticons

    REM - MAPS FOR ESTATES
    %LOGONSERVER%\netlogon\tools\ifmember.exe "xxxFileserver2"
    if errorlevel 1 goto mapestpdrive
    goto skipestpdrive
    :mapestpdrive
    net use p: /delete /YES
    net use p: \\fileserver2\HMHTT$\Finance\Facilities\Private
    net use w: /delete /YES
    net use w: \\fileserver2\HMHTT$\Finance\Facilities\Public
    :skipestpdrive
    REM --- MAPS N DRIVE IS USERS ARE IN HHFS1-OPTHALMIC
    %LOGONSERVER%\netlogon\tools\ifmember.exe "HHFS1Ophthalmic"
    if errorlevel 1 goto mapOptdrive
    goto skipOptdrive
    :mapOptdrive
    net use N: /delete /YES
    net use N: \\hhfs1\Ophthalmic
    :skipOptdrive
    REM --- MAPS H DRIVE IS USERS ARE IN HHFS1server
    %LOGONSERVER%\netlogon\tools\ifmember.exe "HHFS1server"
    if errorlevel 1 goto mapHHFS1drive
    goto skipHHFS1drive
    :mapHHFS1drive
    net use H: /delete /YES
    net use H: \\hhfs1\ERYPCT
    :skipHHFS1drive

    REM --- Installs HFT icons
    REM -- COPY AND INSTALL SHORTCUTS FOR HUMBER STAFF
    %LOGONSERVER%\netlogon\tools\ifmember.exe "Fileserver2Shares"
    if errorlevel 1 goto insthfticons
    goto skipinsthfticons
    :insthfticons
    IF EXIST "C:\PROGRAM FILES\LORENZOSHORTCUTS\LORENZO.ICO" GOTO QUITLORENZOICONS
    CD "C:\PROGRAM FILES"
    IF NOT EXIST LORENZOSHORTCUTS MD LORENZOSHORTCUTS
    CD LORENZOSHORTCUTS
    copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LORENZOSHORTCUTS\LORENZO.ICO" "C:\PROGRAM FILES\LORENZOSHORTCUTS"
    :QUITLORENZOICONS
    IF EXIST "C:\PROGRAM FILES\LORENZOSHORTCUTS\HEALTHROSTER.ICO" GOTO QUITHRICONS
    CD "C:\PROGRAM FILES"
    copy /Y "%LOGONSERVER%\netlogon\icons\Humber\HealthRoster\HealthRoster.ico" "C:\PROGRAM FILES\LORENZOSHORTCUTS"
    :QUITHRICONS
    if exist "C:\Documents and Settings\All Users\Desktop\New LSP Portal.url" del "C:\Documents and Settings\All Users\Desktop\New LSP Portal.url"
    if exist "%userprofile%\Desktop\New LSP Portal.url" del "%userprofile%\desktop\New LSP Portal.url"
    if not exist "%userprofile%\desktop\New LSP Portal (Read Only).url" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LorenzoShortcuts\New LSP Portal (Read Only).url" "%userprofile%\desktop"
    if not exist "%userprofile%\desktop\Lorenzo.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LorenzoShortcuts\Lorenzo.lnk" "%userprofile%\desktop"

    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\Lorenzo.lnk" cd "%AllUsersProfile%\Start Menu\Programs"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\Lorenzo.lnk" md "Better Together"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\Lorenzo.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\LorenzoShortcuts\Lorenzo.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\HealthRoster.lnk"copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxx\HealthRoster.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\EmplyeeOnline.lnk"copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxx\EmployeeOnline.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\RosterPerform.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxxRosterPerform.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"
    if not exist "%AllUsersProfile%\Start Menu\Programs\Better Together\Bank Staff.lnk" copy /Y "%LOGONSERVER%\netlogon\icons\xxx\xxx\Bank Staff.lnk" "%AllUsersProfile%\Start Menu\Programs\Better Together"

    :skipinsthfticons
    REM --- Installs CHCP icons
    %LOGONSERVER%\netlogon\tools\ifmember.exe "CHCPServer"
    if errorlevel 1 goto instportchcp
    goto skipinstportchcp
    :instportchcp
    copy /Y "%LOGONSERVER%\netlogon\icons\CHCP\*.*" "%userprofile%\desktop"
    :skipinstportchcp
    REM --- Installs xxx icons
    %LOGONSERVER%\netlogon\tools\ifmember.exe "xxxServer"
    if errorlevel 1 goto instportxxx
    goto skipinstporthull
    :instporthull
    copy /Y "%LOGONSERVER%\netlogon\icons\xxx\*.*" "%userprofile%\desktop"
    :skipinstportxxx

    REM --- DON'T PUT ANYTHING UNDER HERE ---

    EXIT
     

Share This Page

Loading...