Windows 10: Create Multipurpose batch file

Page 1 of 2 12 LastLast
  1.    24 Sep 2016 #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 ComputerSystem Spec

  2.    24 Sep 2016 #2

    reddwarf4ever said: View Post
    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 ComputerSystem Spec

  3.    24 Sep 2016 #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 ComputerSystem Spec

  4.    24 Sep 2016 #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 ComputerSystem Spec

  5.    25 Sep 2016 #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 ComputerSystem Spec

  6.    25 Sep 2016 #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):

    Click image for larger version. 

Name:	menu.gif 
Views:	29 
Size:	445.5 KB 
ID:	103166

    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 ComputerSystem Spec

  7.    25 Sep 2016 #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 ComputerSystem Spec

  8.    25 Sep 2016 #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 ComputerSystem Spec

  9.    26 Sep 2016 #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 ComputerSystem Spec

  10.    26 Sep 2016 #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 ComputerSystem Spec


 
Page 1 of 2 12 LastLast

Related Threads
Batch File Help in Software and Apps
I've never dabbled much in batch files, as I've usually been able to find pre-made ones to do what I wanted. We have an application that handles user data backups. It has three services, and at times, one or two of the three don't start...
Hi there forum, how do you change the Visual effects using a batch file or registry file. Thanks, Edward.
How do I create a batch file to convert all of my iPod Photo Cache all at once to jpeg. I have SmartIV ImageZipper Image Converter 1.0.2. I have read how to use other software to do this but I can't figure out the command with this software. I have...
Solved Writhing Batch File in General Support
Here is my batch file but it will not delete the file? Must be missing something :( del "C:\Users\Larry\AppData\Local\TractorParts\tractor\ConfigSetting" Trying to delete the ConfigSetting File
I am trying to use psshutdown.exe to create a batch file to shutdown my PC. I want the equivalent of "Shut Down" from the start menu. Should I use the switch -k or -s. I do not understand the difference between these arguments and I want to...
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 14:03.
Find Us