cmd /k command

Page 2 of 2 FirstFirst 12

  1. Posts : 21,421
    19044.1586 - 21H2 Pro x64
       #11

    Thanks for the update hukre. I'll have to try myself when I get back to my PC.
      My Computer


  2. Posts : 16,946
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #12

    hukre said:
    Now I want to put the shortcut on the Taskbar. This is where my problem started. After right-clicking on the
    icon, the small window which comes up does not include the choice "Pin to taskbar"
    hukre,

    Alter the shortcut's Target field.

    Right-click on the shortcut, select Properties.
    cmd /k command-properties.png

    In front of the path to the batch file, type in
    explorer.exe {followed by a space}
    so it becomes something like
    explorer.exe D:\Desktop\SomeBachFile.bat
    and click on OK.

    Now right-click on the [modified] shortcut again and it will offer the option to Pin to Taskbar
    cmd /k command-pin-taskbar.png


    All the best,
    Denis
    Last edited by Try3; 23 Oct 2021 at 15:22.
      My Computer


  3. Posts : 21,421
    19044.1586 - 21H2 Pro x64
       #13

    hukre said:
    Dear Steve 108'
    I very much appreciate your assistance in getting my problem resolved.

    I planned to run a batch file from a shortcut so I placed a shortcut on the desktop, and
    when I double click on it, the batchfile runs ok.

    Now I want to put the shortcut on the Taskbar. This is where my problem started. After right-clicking on the
    icon, the small window which comes up does not include the choice "Pin to taskbar" as it does when you
    right-click on some of the other shortcuts on the desktop; dragging it onto the taskbar is not accepted.

    After looking into this, I found that in order to get it on the taskbar, you have to precede the shortcut target
    with cmd /c, to make the target look like: cmd /c "C:\users\batchfiles\testing.bat".
    Now when you right click on the desktop icon again, the choice of "Pin to taskbar" is restored.

    I since discovered that when you run a batchfile from the shortcut, the black cmd screen pops up but
    disappears in less than a second.

    When I first noted the problem described in my original question, I used the cmd /c command on a .exe file,
    where the black command screen stayed on for about 2 seconds. In the mean time, it turns out that the
    cmd /c command was not needed in the shortcut for the .exe file.
    Your way worked for me and what I said earlier about creating a shortcut didn't.
      My Computer


  4. Posts : 10
    windows 10
    Thread Starter
       #14

    Thank you Try3 for your detailed input. It works just great. I am just astonished about all those tips like yours, my search on google didn't turn up anything, and I wonder if anything like that is written down in any Windows 10 book or if people find these by trial and error.
    hukre
      My Computer


  5. Posts : 16,946
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #15

    Much of it is trial on error [but guided by reason in many cases].
    There's a lot of guidance in TenForumsTutorials - see, for example, Pin File to Taskbar [renaming method] - TenForumsTutorials
    There's also a lot of guidance in other TenForums threads - see, for example, Pin anything to taskbar [Edwin renaming method] - TenForums

    It's really worth making time to browse through the Tutorial index - there's a shortcut to it at the top of every page.
    - At the foot of the Tutorial index is a shortcut to download it as a spreadsheet.
    - I download a new copy each month.
    - By downloading it as a spreadsheet I can benefit from Excel's excellent filtering capabilities when I search for topics of interest.
    - Tutorials are also listed by category at Tutorials - there's also a shortcut to that at the top of every page.
    - Both tutorial lists are searchable.
    - You can also search for TenForumsTutorials in many general search engines, such as Google, by adding site:tenforums.com/tutorials after your search term. For example,
    taskbar toolbars site:tenforums.com/tutorials

    You can search TenForums using the search box in the top-right corner of all TenForums webpages or using Advanced Search - TenForums
    - You can also search TenForums threads in many general search engines, such as Google, by adding site:tenforums.com after your search term. For example,
    Search for drivers by HardwareID site:tenforums.com
    - [This is what the search box in the top-right corner of TenForums webpages does automatically]

    Welcome to TenForums,
    Denis
      My Computer


  6. Posts : 10
    windows 10
    Thread Starter
       #16

    Thank you very much Try3 for posting such great information. I will certainly make use of it instead of wasting many hours searching for solutions to my problems on the internet only to find out that some of them are several years old and don't apply to the latest vesrsion of Windows 10 anymore.
      My Computer


  7. Posts : 1,203
    11 Home
       #17

    The easiest way to make the cmd /c window invisible is to use a VBScript that contains the following code:

    Code:
    Dim wshShell
    Set wshShell = CreateObject("WScript.Shell")
    wshShell.Run """%windir%\System32\cmd.exe"" /c start ""My window title"" ""C:\users\batchfiles\testing.bat""", 0
    Set wshShell = Nothing
    You can create a new shortcut that points to this .vbs file.

    - - - Updated - - -

    ...Or if you just want to run the batchfile invisibly:
    Code:
    Dim wshShell
    Set wshShell = CreateObject("WScript.Shell")
    wshShell.Run """C:\users\batchfiles\testing.bat""", 0
    Set wshShell = Nothing
      My Computers


 

  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 15:57.
Find Us




Windows 10 Forums