Question about the "run" command
-
kuiwu_cn
Question about the "run" command
There is a BAT file in the directory "F:\Test\".
I created a shortcut on this BAT file.
The content of the BAT file is:
@ECHO OFF
CLS
PAUSE
I run this shortcut with a script:
run quote ("F:\Test\Test.lnk"),,2,1;
But there is no BAT window, why?
I created a shortcut on this BAT file.
The content of the BAT file is:
@ECHO OFF
CLS
PAUSE
I run this shortcut with a script:
run quote ("F:\Test\Test.lnk"),,2,1;
But there is no BAT window, why?
To see the attached files, you need to log into the forum.
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Question about the "run" command
XY does not internally resolve that .lnk, so either use
or e.g.:
Code: Select all
run property("#ShortcutTarget", "F:\Test\Test.lnk"),,2,1;Code: Select all
open "F:\Test\Test.lnk";One of my scripts helped you out? Please donate via Paypal
-
kuiwu_cn
Re: Question about the "run" command
My real need is:
Let the BAT file get administrator privileges. I set "run with administrator" on the properties of shortcuts, so that BAT can get administrator privileges.
Thanks very much。
Your method is very good, but it can't help me.
Let the BAT file get administrator privileges. I set "run with administrator" on the properties of shortcuts, so that BAT can get administrator privileges.
Thanks very much。
Your method is very good, but it can't help me.
To see the attached files, you need to log into the forum.
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Question about the "run" command
Then let the .bat file elevate itself and if this doesn't cut it, use an external tool, e.g.:
https://jpassing.com/2007/12/08/launch- ... mand-line/
https://jpassing.com/2007/12/08/launch- ... mand-line/
Code: Select all
REM ### Admin Check ########################################
REG QUERY "HKU\S-1-5-19" >NUL 2>NUL && GOTO :ENDUAC
SET "vbsFile=%TEMP%\~getAdmin.vbs"
IF "%1" NEQ "" (FOR /F "tokens=*" %%I in ('ECHO %*') DO SET "param=%%~I")
ECHO Set UAC = CreateObject^("Shell.Application"^)> "%vbsFile%"
ECHO UAC.ShellExecute "cmd", "/c """"%~s0"" ""%param%""""", "", "runas", ^1>> "%vbsFile%"
CSCRIPT "%vbsFile%" //Nologo
IF EXIST "%vbsFile%" DEL /Q "%vbsFile%" >NUL 2>NUL
EXIT /B
:ENDUAC
One of my scripts helped you out? Please donate via Paypal
-
kuiwu_cn
Re: Question about the "run" command
It's very interesting that the script below can execute normally. Why? Is it a BUG?
run quote ("F:\Test\Test.lnk"),,0,1;
run quote ("F:\Test\Test.lnk"),,0,1;
To see the attached files, you need to log into the forum.
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Question about the "run" command
Maybe shell lnk resolving isn't used / executed if XY needs to wait for it's termination
One of my scripts helped you out? Please donate via Paypal
-
kuiwu_cn
Re: Question about the "run" command
I'm very sorry, but my English is not very good. I didn't understand your meaning. Can you explain it?
-
kuiwu_cn
Re: Question about the "run" command
highend wrote:Maybe shell lnk resolving isn't used / executed if XY needs to wait for it's termination
May I trouble you to explain it, thank you.
-
highend
- Posts: 15004
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Question about the "run" command
If this doesn't work:
and this does:
then XYplorer's script command "run" does not do the necessary resolving of the .lnk shortcut
to its real file when 2 is used for the wait parameter. Probably a bug then (Don needs to answer this)
Code: Select all
run quote("F:\Test\Test.lnk"),,2,1;Code: Select all
run quote("F:\Test\Test.lnk"),,0,1;to its real file when 2 is used for the wait parameter. Probably a bug then (Don needs to answer this)
One of my scripts helped you out? Please donate via Paypal
-
kuiwu_cn
Re: Question about the "run" command
If I have a BAT file, I want to get administrator privileges when I double-click it. I only need to add "(Need ADMIN)" in the file name. I have implemented this function already.
XYplorer is a great software. I like it very much. I use it every day.
Code: Select all
@ECHO OFF
TITLE 另一个BAT执行完毕后,该BAT会自动退出
"%~dp0Let_the_BAT_File_Have_ADMIN.lnk" %~1 %~2
XYplorer is a great software. I like it very much. I use it every day.
To see the attached files, you need to log into the forum.
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Question about the "run" command
I can only confirm these findings. With the "wait" flag set to 1 or 2, the CreateProcess function (Windows API) is needed but this function does not support LNK files.highend wrote:If this doesn't work:and this does:Code: Select all
run quote("F:\Test\Test.lnk"),,2,1;then XYplorer's script command "run" does not do the necessary resolving of the .lnk shortcutCode: Select all
run quote("F:\Test\Test.lnk"),,0,1;
to its real file when 2 is used for the wait parameter. Probably a bug then (Don needs to answer this)
In the bext beta you will at least get an error message.
FAQ | XY News RSS | XY X
XYplorer Beta Club