Create Multipurpose batch file

Page 1 of 2 12 LastLast

  1. Posts : 1,523
    windows 10 PRO
       #1

    Create Multipurpose batch file


    Hope this is the correct sub forum for this..

    Often use a variety of command line functions e.g. winver / netplwiz etc etc

    Is there a way of creating a batchfile to include multiple commands with a number option to select...would be so handy

    i.e. 1 Netplwiz
    2 Winver
    3 ???
    Thanks
      My Computer


  2. Posts : 15,480
    Windows10
       #2

    reddwarf4ever said:
    Hope this is the correct sub forum for this..

    Often use a variety of command line functions e.g. winver / netplwiz etc etc

    Is there a way of creating a batchfile to include multiple commands with a number option to select...would be so handy

    i.e. 1 Netplwiz
    2 Winver
    3 ???
    Thanks
    Sure it is possible with command line arguments.

    Batch Files - Create a Menu to Execute Commands - Windows 7 Help Forums
      My Computer


  3. Posts : 1,523
    windows 10 PRO
    Thread Starter
       #3

    Thanks so much, that is exactly what need, just need a resource for handy command line arguments...

    PS is there a third party program that would do this
      My Computer


  4. Posts : 1,523
    windows 10 PRO
    Thread Starter
       #4

    I have created a batch file for winver and netplwiz, but when i try ipconfig or sfc /scannow they require admin rights....what can i add to run these without entering my password every time....
    Thanks
      My Computer


  5. Posts : 1,523
    windows 10 PRO
    Thread Starter
       #5

    Have done so more work on a batchfile...Have created a shortcut to it and given this admin rights, but still some commands seem to need something else..

    a little help please

    [QUOTE]




    ECHO OFF
    CLS
    :MENU
    cls
    ECHO.
    ECHO ...............................................
    ECHO PRESS 0 - 9 to select your task, or E to EXIT.
    ECHO ...............................................
    ECHO.
    ECHO 1 - Windows Version
    ECHO 2 - User Accounts Login option
    ECHO 3 - Internet protocol configuration
    ECHO 4 - System file checker
    ECHO 5 - Checkdisk
    ECHO 6 - Clean up
    ECHO 7 - Computer Management
    ECHO 8 - System Restore
    ECHO 9 - DirectX diagnostics
    ECHO 0 - EXIT


    ECHO.


    CHOICE /C:0123456789
    IF ERRORLEVEL 0 SET M=0
    IF ERRORLEVEL 1 SET M=1
    IF ERRORLEVEL 2 SET M=2
    IF ERRORLEVEL 3 SET M=3
    IF ERRORLEVEL 4 SET M=4
    IF ERRORLEVEL 5 SET M=5
    IF ERRORLEVEL 6 SET M=6
    IF ERRORLEVEL 7 SET M=7
    IF ERRORLEVEL 8 SET M=8
    IF ERRORLEVEL 9 SET M=9


    IF %M%==0 GOTO EOF
    IF %M%==1 GOTO WINDOWS VERSION
    IF %M%==2 GOTO User Accounts Login option
    IF %M%==3 GOTO Internet protocol configuration
    IF %M%==4 GOTO System file checker
    IF %M%==5 GOTO Checkdisk
    IF %M%==6 GOTO Clean up
    IF %M%==7 GOTO Computer Management
    IF %M%==8 GOTO System Restore
    IF %M%==9 GOTO DirectX diagnostics


    cls


    :WINDOWS VERSION
    winver
    GOTO MENU


    :USER ACCOUNTS LOGIN OPTION
    netplwiz
    GOTO MENU


    :Internet protocol configuration
    ipconfig
    GOTO MENU


    :System file checker
    start runas SFC /Scannow
    GOTO MENU


    :Checkdisk
    Chkdsk
    GOTO MENU


    :Cleanup
    Cleanmgr
    GOTO MENU


    :Computer Management
    Compmgmt
    GOTO MENU


    :System Restore
    wscui.cpi
    GOTO MENU


    irectX diagnostics
    Dxdiag
    GOTO MENU
    Last edited by reddwarf4ever; 25 Sep 2016 at 14:34.
      My Computer


  6. Posts : 75
    21H1 (19043.1415)
       #6

    I was just looking into making something like this a few weeks ago, and decided to go with an AutoIt GUI.

    Here's an example you could use (+ a gif):

    Create Multipurpose batch file-menu.gif

    Code:
    #NoTrayIcon
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    
    ; Add/remove buttons here, adjusting array numbers accordingly
    Local $btn[3]
        $btn[0] = 'Example Cmd'
        $btn[1] = 'Another One'
        $btn[2] = 'One More'
    
    ; Make sure func names match button text, minus spaces
    Func ExampleCmd()
        Run('rundll32 netplwiz.dll,UsersRunDll')
    EndFunc
    Func AnotherOne()
        Run('winver')
    EndFunc
    Func OneMore()
        Run('cmd /k ipconfig')
    EndFunc
    
    ; GUI dimensions/positions
    Local $btnCount = UBound($btn)
    Local $btnWidth = 155
    Local $btnHeight = 55
    Local $btnPad = 6
    Local $btnX = $btnPad * 1.2
    Local $btnY[$btnCount]
        $btnY[0] = $btnPad * 1.8
        For $i = 1 To $btnCount - 1
            $btnY[$i] = $btnY[$i - 1] + $btnHeight + $btnPad
        Next
    Local $winWidth = $btnWidth + $btnX * 2
    local $winHeight = ($btnHeight + $btnPad) * $btnCount + $btnPad * 2.4
    Local $winX = 0
    Local $winY = @desktopHeight - 41 - $winHeight
    
    ; GUI
    Local $win = GUICreate('', $winWidth, $winHeight, $winX, $winY, $WS_POPUP + $WS_BORDER, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    GUISetFont(14, 0, 0, 'Segoe UI')
    For $i = 0 To $btnCount - 1
        GUICtrlCreateButton($btn[$i], $btnX, $btnY[$i], $btnWidth, $btnHeight)
        GUICtrlSetOnEvent(-1, StringStripWS($btn[$i], 8))
    Next
    Opt('GUIOnEventMode', 1)
    GUISetState(@SW_SHOW)
    While 1
        If WinActive($win) = 0 Then
            Exit
        EndIf
        Sleep(50)
    WEnd
    You'll just need to have AutoIt installed, paste that into an .au3, edit the commands, and create a shortcut to it (that icon is in imageres.dll). You also might want to adjust the window X/Y positions to have it pop up adjacent to wherever you keep the shortcut.
      My Computer


  7. Posts : 1,523
    windows 10 PRO
    Thread Starter
       #7

    Thanks given me something to think about....

    still would like like to know what's wrong with my batch file commands....


    PS where did you get Windows 11 from LOL
      My Computer


  8. Posts : 75
    21H1 (19043.1415)
       #8

    Haha, I wish that were the future of Windows. It's just Classic Shell with a few icons I found various places (they're here in my Google Drive if you want em).

    Sorry to not really answer your question again, but I kinda skipped over the whole batch scripting thing and went straight into PowerShell. Here's what your script might look like in a .ps1:

    Code:
    function Commands {
    Clear-Host
    $Entry = Read-Host @'
    1 - Windows Version
    2 - User Accounts Login option
    3 - Internet protocol configuration
    4 - System file checker
    5 - Checkdisk
    6 - Clean up
    7 - Computer Management
    8 - System Restore
    9 - DirectX diagnostics
    0 - EXIT
    '@
    if ($Entry -eq 1) {winver; Commands}
    elseif ($Entry -eq 2) {netplwiz; Commands}
    elseif ($Entry -eq 3) {Clear-Host; ipconfig; Pause; Commands}
    elseif ($Entry -eq 4) {Clear-Host; sfc /scannow; Pause; Commands}
    elseif ($Entry -eq 5) {Clear-Host; chkdsk; Pause; Commands}
    elseif ($Entry -eq 6) {cleanmgr; Commands}
    elseif ($Entry -eq 7) {compmgmt; Commands}
    elseif ($Entry -eq 8) {wscui; Commands}
    elseif ($Entry -eq 9) {dxdiag; Commands}
    elseif ($Entry -eq 0) {Exit}
    else {Commands}
    } 
    Commands
      My Computer


  9. Posts : 1,523
    windows 10 PRO
    Thread Starter
       #9

    Thank you.......looks much tidier.....

    Opened a pwershell window, pasted code, but how / do i need to save it, how do i run it

    thanks
    Last edited by reddwarf4ever; 26 Sep 2016 at 06:31.
      My Computer


  10. Posts : 75
    21H1 (19043.1415)
       #10

    First, you'll have to enable PS script execution on your system. Open PowerShell as admin and enter:
    Code:
    Set-ExecutionPolicy RemoteSigned
    Now create a .ps1 file and paste the script in.

    To run it, you can right-click to "Run with PowerShell", or if you want to run with a more direct click, the easiest way is to create a shortcut with a target like (and must be single quotes):
    Code:
    powershell & 'C:\Path\To\Your.ps1'
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:00.
Find Us




Windows 10 Forums