[Batch] The Official Batch File Repository - Learn & ask questions about batch files

Discussion in 'Scripting' started by timesurfer, Oct 11, 2010.

  1. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,251
    22,365
    210
    #241 Alphawaves, Apr 12, 2012
    Last edited by a moderator: Apr 20, 2017
    Code:
    @echo off
    
    echo Activating Windows 7... 
    cscript //nologo "%windir%\system32\slmgr.vbs" /ipk MHFPT-8C8M2-V9488-FGM44-2C9T3
    cscript //nologo "%windir%\system32\slmgr.vbs" /ilc "%~dp0HP.xrm-ms"
    cscript //nologo "%windir%\system32\slmgr.vbs" /ato
     
  2. sanjose

    sanjose MDL Member

    Jan 23, 2012
    184
    21
    10
    #242 sanjose, Apr 12, 2012
    Last edited by a moderator: Apr 20, 2017
    @Alphawaves

    Thanks a lot for your help. Just a curiosity, What does //nologo mean, please ?

    Have a good day.


     
  3. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,251
    22,365
    210
    #243 Alphawaves, Apr 12, 2012
    Last edited: Apr 13, 2012
    Hi sanjose, It specifies that the Windows Script Host banner is not displayed before the script runs.
    Also displays result of its actions as opposed to //B ;)

    EDIT: Updated response to you sanjose
     
  4. sanjose

    sanjose MDL Member

    Jan 23, 2012
    184
    21
    10
    #244 sanjose, Apr 19, 2012
    Last edited: Apr 20, 2012
    @Alphawaves

    Thanks for your editing.

    To All,

    One more question please.

    Can we backup CERT.xrm-ms from brand new PC with Command Lines ( I mean a file .cmd or .bat ) instead of using SLIC ToolKit 3.2 ?

    If Yes, Can you help me have it, please ?

    Thanks for your concern.

     
  5. racky29

    racky29 MDL Senior Member

    Aug 2, 2007
    285
    93
    10
    #245 racky29, Apr 22, 2012
    Last edited: Apr 22, 2012
  6. sanjose

    sanjose MDL Member

    Jan 23, 2012
    184
    21
    10
    @racky29

    Thanks for all your info. I think that we can not maybe backup CERT.xrm-ms from brand new PC with Command Lines.

     
  7. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,513
    7,174
    120
    Batch files is an outaded "programming" method for develop scripts...

    The CMD.EXE haven't the resources to extract an certificate from Tokens.dat...

    You can use the Alphawaves tool to backup via command line.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. raghuveers

    raghuveers MDL Novice

    Jul 15, 2012
    3
    0
    0
    Is there any Script Written or Available to find Unused IP Address in a IP Pool.
     
  9. frwil

    frwil MDL Addicted

    Sep 22, 2008
    542
    198
    30
    #249 frwil, Nov 2, 2012
    Last edited by a moderator: Apr 20, 2017
    I'm a bit lost - is there a way to write xml file by echo?
    For example, this:
    Code:
    > unattend.xml echo "<?xml version="1.0" encoding="utf-8"?><unattend></unattend>"
    
    will produce file with '' at the start and the end of content (which shouldn't be there). And of course without quotations around < and > script won't work at all...
     
  10. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,251
    22,365
    210
    #250 Alphawaves, Nov 3, 2012
    Last edited by a moderator: Apr 20, 2017
    Code:
    echo ^<?xml version="1.0" encoding="utf-8"?^>^<unattend^>^</unattend^> >"%~dp0unattend.xml"
    example:
    Code:
    echo             ^<OOBE^> >>"%~dp0unattend.xml"
    echo                 ^<HideEULAPage^>true^</HideEULAPage^> >>"%~dp0unattend.xml"
    echo                ^<HideWirelessSetupInOOBE^>true^</HideWirelessSetupInOOBE^> >>"%~dp0unattend.xml"
    echo                ^<ProtectYourPC^>1^</ProtectYourPC^> >>"%~dp0unattend.xml"
    echo                ^<NetworkLocation^>Home^</NetworkLocation^> >>"%~dp0unattend.xml"
    echo            ^</OOBE^> >>"%~dp0unattend.xml"
    echo            ^<VisualEffects^> >>"%~dp0unattend.xml"
    echo                ^<FontSmoothing^>Standard^</FontSmoothing^> >>"%~dp0unattend.xml"
    echo            ^</VisualEffects^> >>"%~dp0unattend.xml"
     
  11. calpol

    calpol MDL Junior Member

    Dec 5, 2009
    98
    5
    0
    Hi All,

    I installed windows 8 and backed up 2 files Tokens.dat & Data.dat in case of the future use. Then I place these two files in a folder named Windows 8 Back-up. I just re-installed windows 8 and try to write command lines in a .cmd file to restore 2 files Tokens.dat & Data.dat as click run this .cmd file. I follow the steps and use command lines for Windows 7. Unfortunatelly, it does NOT work in Windows 8.

    Does anybody know how to write the command lines to copy and overwrite Tokens.dat & Data.dat for the fresh Windows installation. Help me please.

    Here's the path: C:\Windows\System32\spp\store ( Tokens.dat & Data.dat in store folder )

    I know that we can use Advanced Tokens Manager - The Activation Backup Solution by Josh Cell, but I 'd like to use a .cmd file.

    Thank you so much in advance for your help.
     
  12. calpol

    calpol MDL Junior Member

    Dec 5, 2009
    98
    5
    0
    #252 calpol, Dec 4, 2012
    Last edited by a moderator: Apr 20, 2017
    Thanks for your info. I'll try and tell you it works or not.
     
  13. calpol

    calpol MDL Junior Member

    Dec 5, 2009
    98
    5
    0
    Hi all,

    I'm running a .cmd file on Windows 8 and I found out a line as below mentioned.
    How can I get rid of the line " More help is available by typing NET HELPMSG 3521 " ? Do I have to add any command line ? please advise !

    Thanks in advanced

    [​IMG]
     
  14. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,251
    22,365
    210
    #254 Alphawaves, Dec 8, 2012
    Last edited by a moderator: Apr 20, 2017
    Have you tried adding:

    Code:
    2>nul
    at end of net stop sppsvc command to redirect error messages to nul :eek:

    or

    Code:
    >nul 2>&1
    which will redirect error and output to nul ;)
     
  15. calpol

    calpol MDL Junior Member

    Dec 5, 2009
    98
    5
    0
    #255 calpol, Dec 8, 2012
    Last edited by a moderator: Apr 20, 2017
    Hi Alphawaves,

    I used this to test Administrative Privileges. Is this something wrong ?

    Code:
    @echo off
    NET SESSION >nul 2>&1
    IF %ERRORLEVEL% EQU 0 (
    goto mainmenu
    ) else (
    goto exit
    )
    :mainmenu

     
  16. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,251
    22,365
    210
    #256 Alphawaves, Dec 8, 2012
    Last edited by a moderator: Apr 20, 2017
    Looks ok here calpol
     
  17. sanjose

    sanjose MDL Member

    Jan 23, 2012
    184
    21
    10
    #257 sanjose, Mar 22, 2013
    Last edited: Mar 22, 2013
    Please help me with the file .bat or .cmd how to block the sites in hosts for Windows 8 as follows:
    contents including:
    1. Administrative Privileges
    2. sites ex:
    127.0.0.1 www.gohome.net
    127.0.0.1 www.backtoschool.net
    3. Press any key to open the hosts file

    Thanks so much for your help in advance
     
  18. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    18,823
    19,035
    340
  19. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Will post that code soon...

    Are currently changing Trilogy to Duality

    TS

    :shisha:
     
  20. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #260 timesurfer, Mar 23, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    .cmd file must be ran as admin which is this code

    Code:
    cls
    mode con: cols=49 lines=12
    REG QUERY "HKU\S-1-5-19" >NUL 2>&1 && (
    GOTO mainmenu
    ) || (
    echo Right click Trilogy and run as administrator...
    echo.
    pause
    GOTO exit
    )
    Code to install/uninstall hosts file entry

    Code:
    CLS
    SET hosts=%windir%\system32\drivers\etc\hosts
    findstr /i "3dns-2.adobe.com" %hosts% >nul
    IF %ERRORLEVEL% EQU 0 (
    echo ACS5.5T is already installed...
    ping -n 5 127.0.0.1 >nul
    goto ACS5.5T
    )
    attrib -r %hosts%
    echo. >>%hosts%
    FOR %%A IN (
    3dns-2.adobe.com
    3dns-3.adobe.com
    activate.adobe.com
    activate.wip3.adobe.com
    activate-sea.adobe.com
    activate-sjc0.adobe.com
    adobe-dns.adobe.com
    adobe-dns-2.adobe.com
    adobe-dns-3.adobe.com
    adobeereg.com
    ereg.adobe.com
    ereg.wip3.adobe.com
    hl2rcv.adobe.com
    practivate.adobe.com
    wip3.adobe.com
    wwis-dubc1-vip60.adobe.com
    www.adobeereg.com
    ) DO (
     echo 127.0.0.1 %%A >>%hosts%
    )
    attrib +r %hosts%
    echo ACS5.5T has been successfully installed...
    ping -n 5 127.0.0.1 >nul
    GOTO ACS5.5T
    
    :UninstallACS5.5T
    CLS
    SET hosts=%windir%\system32\drivers\etc\hosts
    findstr /i "3dns-2.adobe.com" %hosts% >nul
    IF %ERRORLEVEL% NEQ 0 (
    echo ACS5.5T is already uninstalled...
    ping -n 5 127.0.0.1 >nul
    goto ACS5.5T
    )
    attrib -r %hosts%
    FOR %%A IN (
    3dns-2.adobe.com
    3dns-3.adobe.com
    activate.adobe.com
    activate.wip3.adobe.com
    activate-sea.adobe.com
    activate-sjc0.adobe.com
    adobe-dns.adobe.com
    adobe-dns-2.adobe.com
    adobe-dns-3.adobe.com
    adobeereg.com
    ereg.adobe.com
    ereg.wip3.adobe.com
    hl2rcv.adobe.com
    practivate.adobe.com
    wip3.adobe.com
    wwis-dubc1-vip60.adobe.com
    www.adobeereg.com
    ) DO (
     MOVE %hosts% hosts.bak >NUL
     FINDSTR /V /C:"%%A" hosts.bak > %hosts%
     DEL /F /Q hosts.bak
    ) 
    attrib +r %hosts%
    echo ACS5.5T has been successfully uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO ACS5.5T
    Code to open hosts file then auto closes

    Code:
    :StatusACS5.5T
    mode con: cols=38 lines=19
    START "" "CMD /C color 06 & type %systemroot%\system32\drivers\etc\hosts & >NUL ping -n 5 127.0.0.1"
    GOTO ACS5.5T