Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: WIN10 desktop shortcut properties  (Read 15096 times)

0 Members and 1 Guest are viewing this topic.

dc4580

    Topic Starter


    Beginner
    • Experience: Beginner
    • OS: Windows XP
    WIN10 desktop shortcut properties
    « on: May 26, 2020, 10:47:35 PM »
    Can I run commands from a desktop shortcut ( 3 commands )?  I want to open the command prompt ( CMD ) and i want to change the directory in the command prompt box to C:\perl.  I also want the command prompt environment to be administration.  Can I do these things in one shortcut?

    Thanks for any help given.

    Dave Cox

    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: WIN10 desktop shortcut properties
    « Reply #1 on: May 27, 2020, 03:22:10 AM »
    Hi  ;)
    Give a try for this batch script and tell me the results  :D
    • First we launch our batch script as Admin
    • Create our Shortcut with HotKey [CTRL+ALT+P] ; So we can launch our script in this situation too (-_°)
    • Change Directory to C:\Perl
    Perl-Command.bat
    Code: [Select]
    @echo off
    REM This Batch script is Written by Hackoo on 27/05/2020 @ 10:25
    Title Run as admin using Powershell to open the command prompt on C:\perl
    REM Starting our batch script as admin
    If [%1] NEQ [Admin] Goto RunAsAdmin
    ::---------------------------------------------------------------------------------------------------
    :Main
    REM Create our Shortcut with HotKey too (°_-) [CTRL+ALT+P] can launch our script too ;)
    Call :CreateShortcut
    REM Change Directory to C:\Perl
    CMD /K CD /D C:\Perl
    EXIT /B
    ::---------------------------------------------------------------------------------------------------
    :RunAsAdmin
    cls & color 0B & Mode 90,5
    echo(
    echo(            ===========================================================
    echo(                  Please wait a while ... Running as Admin ....
    echo(            ===========================================================
    Powershell start -verb runas '%0' Admin & Exit
    ::---------------------------------------------------------------------------------------------------
    :CreateShortcut
    Powershell ^
    "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Desktop\%~n0.lnk'); ^
    $s.TargetPath='%~f0'; ^
    $s.WorkingDirectory='%~dp0'; ^
    $s.IconLocation='PowerShell.exe,0'; ^
    $s.HotKey='CTRL+ALT+P'; ^
    $s.Save()"
    Exit /B
    ::---------------------------------------------------------------------------------------------------

    dc4580

      Topic Starter


      Beginner
      • Experience: Beginner
      • OS: Windows XP
      Re: WIN10 desktop shortcut properties
      « Reply #2 on: May 27, 2020, 03:41:09 PM »
      Ran as directed and got to my directory.

      OK.  You understand that I would like to achieve this through use of a desktop shortcut, I hope.

      Can be done to your knowledge?

      Thanks for your help.  I appreciate it.

      Dave

      Hackoo



        Hopeful
      • Thanked: 42
      • Experience: Expert
      • OS: Windows 10
      Re: WIN10 desktop shortcut properties
      « Reply #3 on: May 28, 2020, 02:24:13 AM »
      Ran as directed and got to my directory.
      OK.  You understand that I would like to achieve this through use of a desktop shortcut, I hope.
      Can be done to your knowledge?
      Thanks for your help.  I appreciate it.
      Dave
      Hi  :)
      Did you already test the batch script ?
      If not : Just open your notepad and copy and paste the code above that i posted to you and save it as Perl-Command.bat and execute it by double click

      dc4580

        Topic Starter


        Beginner
        • Experience: Beginner
        • OS: Windows XP
        Re: WIN10 desktop shortcut properties
        « Reply #4 on: May 28, 2020, 02:56:22 AM »
        Yes, I did that.  I worked.  I would like to use the desktop shortcut.

        Can it be done?

        Hackoo



          Hopeful
        • Thanked: 42
        • Experience: Expert
        • OS: Windows 10
        Re: WIN10 desktop shortcut properties
        « Reply #5 on: May 28, 2020, 04:10:07 AM »
        Yes, I did that.  I worked.  I would like to use the desktop shortcut.
        Can it be done?
        What did you mean by i want to use it as desktop shortcut ???
        The script create the shortcut on your desktop or not ?
        Please explain more your aim !

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: WIN10 desktop shortcut properties
        « Reply #6 on: May 28, 2020, 04:26:04 AM »
        Create a shortcut to cmd, then change the target to:

        Code: [Select]
        C:\Windows\System32\cmd.exe /k cd /D C:\perl
        Under the advanced button you can check off "Run as administrator"

        Shortcuts can be set to run as administrator under "advanced" on the shortcut tab (same one as the target).

        Running the shortcut will run an elevated command prompt and automatically change to the C:\perl directory.

        I was trying to dereference Null Pointers before it was cool.

        dc4580

          Topic Starter


          Beginner
          • Experience: Beginner
          • OS: Windows XP
          Re: WIN10 desktop shortcut properties
          « Reply #7 on: May 28, 2020, 01:43:29 PM »
          Yes, I know about the advanced tab, etc.    I've said what I would like to do several times.

          In the shortcut, there are two entries you put in.  The second is the label of the shortcut.  Not even necessary to discuss.

          The first is Location ( normally of a URL ).  I can put CMD in there to open command prompt.  I need also to make the shortcut "Run as administrator" and I would like to do a CD command to get to my directory in the command prompt box opened from the shortcut.  I would like to do these three things in the shortcut.  I don't want to use the .bat frile.

          Thanks

          Dave

          patio

          • Moderator


          • Genius
          • Maud' Dib
          • Thanked: 1769
            • Yes
          • Experience: Beginner
          • OS: Windows 7
          Re: WIN10 desktop shortcut properties
          « Reply #8 on: May 28, 2020, 03:21:53 PM »
          You are missing the point...
          " Anyone who goes to a psychiatrist should have his head examined. "

          dc4580

            Topic Starter


            Beginner
            • Experience: Beginner
            • OS: Windows XP
            Re: WIN10 desktop shortcut properties
            « Reply #9 on: May 28, 2020, 07:41:55 PM »
            Closing this question out.  Unfortunately, it's not resolved.

            Missed the point, eh?  So far, everybody chiming in missed the point of what I want to do.


            patio

            • Moderator


            • Genius
            • Maud' Dib
            • Thanked: 1769
              • Yes
            • Experience: Beginner
            • OS: Windows 7
            Re: WIN10 desktop shortcut properties
            « Reply #10 on: May 28, 2020, 07:47:34 PM »
            BC gave you a simple solution above...
            " Anyone who goes to a psychiatrist should have his head examined. "

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: WIN10 desktop shortcut properties
            « Reply #11 on: May 29, 2020, 04:41:59 AM »



            Yes, I know about the advanced tab, etc.
            It is a button. The advanced button opens a small dialog containing "Run as Administrator".

            Quote
            In the shortcut, there are two entries you put in.  The second is the label of the shortcut.  Not even necessary to discuss.
            You are talking about the "wizard" for creating a new shortcut. you can directly enter
            Code: [Select]
            cmd /k cd /D C:\perl as the target there as well. However you need to open the properties of the shortcut and use the Advanced button to set the shortcut to run as administrator.


            I was trying to dereference Null Pointers before it was cool.