

InterviewSolution
Saved Bookmarks
1. |
Solve : WIN10 desktop shortcut properties? |
Answer» <html><body><p>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?<br/><br/>Thanks for any help given.<br/><br/>Dave CoxHi <br/>Give a try for this batch script and tell me the results <br/></p><ul><li>First we launch our batch script as <a href="https://interviewquestions.tuteehub.com/tag/admin-850174" style="font-weight:bold;" target="_blank" title="Click to know more about ADMIN">ADMIN</a></li><li>Create our Shortcut with HotKey [CTRL+ALT+P] ; So we can launch our script in this situation too (-_°)</li><li>Change Directory to C:\Perl</li></ul><strong>Perl-Command.bat</strong><br/> Code: <a>[Select]</a>echo off<br/>REM This Batch script is Written by Hackoo on 27/05/2020 10:25<br/>Title Run as admin using Powershell to open the command prompt on C:\perl<br/>REM Starting our batch script as admin<br/>If [%1] NEQ [Admin] Goto RunAsAdmin<br/>::---------------------------------------------------------------------------------------------------<br/>:Main<br/>REM Create our Shortcut with HotKey too (°_-) [CTRL+ALT+P] can launch our script too ;)<br/>Call :CreateShortcut<br/>REM Change Directory to C:\Perl<br/>CMD /K CD /D C:\Perl<br/>EXIT /B<br/>::---------------------------------------------------------------------------------------------------<br/>:RunAsAdmin<br/>cls & color 0B & Mode 90,5<br/>echo( <br/>echo( ===========================================================<br/>echo( Please <a href="https://interviewquestions.tuteehub.com/tag/wait-1448592" style="font-weight:bold;" target="_blank" title="Click to know more about WAIT">WAIT</a> a while ... Running as Admin ....<br/>echo( ===========================================================<br/>Powershell start -verb runas '%0' Admin & Exit<br/>::---------------------------------------------------------------------------------------------------<br/>:CreateShortcut<br/>Powershell ^<br/>"$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Desktop\%~n0.lnk'); ^<br/>$s.TargetPath='%~f0'; ^<br/>$s.WorkingDirectory='%~dp0'; ^<br/>$s.IconLocation='PowerShell.exe,0'; ^<br/>$s.HotKey='CTRL+ALT+P'; ^<br/>$s.Save()"<br/>Exit /B<br/>::---------------------------------------------------------------------------------------------------Ran as directed and got to my directory.<br/><br/>OK. You understand that I would like to achieve this through use of a desktop shortcut, I hope.<br/><br/>Can be done to your knowledge?<br/><br/>Thanks for your help. I appreciate it.<br/><br/>Dave Quote from: dc4580 on May 27, 2020, 03:41:09 PM<blockquote>Ran as directed and got to my directory.<br/>OK. You understand that I would like to achieve this through use of a desktop shortcut, I hope.<br/>Can be done to your knowledge?<br/>Thanks for your help. I appreciate it.<br/>Dave<br/></blockquote> Hi <br/>Did you already test the batch script ? <br/>If not : Just open your <a href="https://interviewquestions.tuteehub.com/tag/notepad-581726" style="font-weight:bold;" target="_blank" title="Click to know more about NOTEPAD">NOTEPAD</a> and <a href="https://interviewquestions.tuteehub.com/tag/copy-25621" style="font-weight:bold;" target="_blank" title="Click to know more about COPY">COPY</a> and paste the code above that i posted to you and save it as <strong>Perl-Command.bat</strong> and execute it by double clickYes, I did that. I worked. I would like to use the desktop shortcut.<br/><br/>Can it be done? Quote from: dc4580 on May 28, 2020, 02:56:22 AM<blockquote>Yes, I did that. I worked. I would like to use the desktop shortcut.<br/>Can it be done?<br/></blockquote> What did you mean by i want to use it as desktop shortcut <br/>The script create the shortcut on your desktop or not ?<br/>Please explain more your aim !Create a shortcut to cmd, then change the target to:<br/><br/> Code: <a>[Select]</a>C:\Windows\System32\cmd.exe /k cd /D C:\perl<br/>Under the advanced button you can check off "Run as administrator"<br/><br/>Shortcuts can be set to run as administrator under "advanced" on the shortcut tab (same one as the target). <br/><br/>Running the shortcut will run an elevated command prompt and automatically change to the C:\perl directory.<br/><br/>Yes, I know about the advanced tab, etc. I've said what I would like to do several times.<br/><br/>In the shortcut, there are two entries you put in. The second is the label of the shortcut. Not even necessary to <a href="https://interviewquestions.tuteehub.com/tag/discuss-955675" style="font-weight:bold;" target="_blank" title="Click to know more about DISCUSS">DISCUSS</a>.<br/><br/>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.<br/><br/>Thanks<br/><br/>DaveYou are missing the point...Closing this question out. Unfortunately, it's not resolved.<br/><br/>Missed the point, eh? So far, everybody chiming in missed the point of what I want to do.<br/><br/>BC gave you a simple solution above...<br/><br/><br/> Quote from: dc4580 on May 28, 2020, 01:43:29 PM<blockquote>Yes, I know about the advanced tab, etc.</blockquote> It is a button. The advanced button opens a small dialog containing "Run as Administrator".<br/><br/> Quote<blockquote>In the shortcut, there are two entries you put in. The second is the label of the shortcut. Not even necessary to discuss.</blockquote> You are talking about the "wizard" for creating a new shortcut. you can directly enter <br/> Code: <a>[Select]</a>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.<br/><br/><br/></body></html> | |