Saved Bookmarks
| 1. |
Solve : WIN10 desktop shortcut properties? |
|
Answer» 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?
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 ::---------------------------------------------------------------------------------------------------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 Quote from: dc4580 on May 27, 2020, 03:41:09 PM Ran as directed and got to my directory.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 clickYes, I did that. I worked. I would like to use the desktop shortcut. Can it be done? Quote from: dc4580 on May 28, 2020, 02:56:22 AM Yes, I did that. I worked. I would like to use the desktop shortcut.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 !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. 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 DaveYou are missing the point...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. BC gave you a simple solution above... Quote from: dc4580 on May 28, 2020, 01:43:29 PM 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. |
|