Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
lazna
- Posts: 62
- Joined: 27 Dec 2012 10:54
#1
Post
by lazna » 21 Oct 2023 04:52
As far as VBS is marked as obsolete (and will be removed from next windows version), looking for alternative way of shortcut creation from batch file other than VBS script. Found powershell oneliner
Code: Select all
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$shortcut = New-Object -ComObject WScript.Shell; $link = $shortcut.CreateShortcut('%shortpath%\short_%s_name%.lnk'); $link.TargetPath = '%target%'; $link.WorkingDirectory = '%workdir%'; $link.Arguments = '%params%'; $link.Description = '%desc%'; $link.IconLocation = '%icon%'; $link.WindowStyle = %windowstyle%; $link.Hotkey = '%hotkey_combination%+%letter%'; [console]::CursorVisible = $false; $link.Save()"
but look like this rely on WScript which is de-facto VBS. Does this powershell will work even after VBS engine will be removed?
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 21 Oct 2023 05:28
It's not VBS. It only uses the COM object WScript.Shell which is one out of many that can be instantiated in VBS but not only in VBS. I doubt that they are going to remove COM objects in the near future.
FWIW: MS is telling us that they are about to get rid of VBScript while I've not seen anything about similar intentions for JScript yet. At least I'm not aware of. What do they gain?
Steffen
-
lazna
- Posts: 62
- Joined: 27 Dec 2012 10:54
#3
Post
by lazna » 22 Oct 2023 04:45
thanks for explanation
-
DOSadnie
- Posts: 143
- Joined: 21 Jul 2022 15:12
- Location: Coding Kindergarten
#4
Post
by DOSadnie » 22 Oct 2023 09:07
aGerman wrote: ↑21 Oct 2023 05:28
[...]
FWIW: MS is telling us that they are about to get rid of VBScript while I've not seen anything about similar intentions for JScript yet. At least I'm not aware of. What do they gain?
And why would they make it impossible to run
VBS scripts, when
BAT scripting has not been ditched long time after introduction of
PS1?
-
lazna
- Posts: 62
- Joined: 27 Dec 2012 10:54
#5
Post
by lazna » 22 Oct 2023 13:06
DOSadnie wrote: ↑22 Oct 2023 09:07
aGerman wrote: ↑21 Oct 2023 05:28
[...]
FWIW: MS is telling us that they are about to get rid of VBScript while I've not seen anything about similar intentions for JScript yet. At least I'm not aware of. What do they gain?
And why would they make it impossible to run
VBS scripts, when
BAT scripting has not been ditched long time after introduction of
PS1?
VBS will be an optional component, guessing for security reasons. About BAT scripting,
read this
-
lazna
- Posts: 62
- Joined: 27 Dec 2012 10:54
#6
Post
by lazna » 22 Oct 2023 13:40
Just discovered the oneliner from first post of this thread display cursor if this one is intentionaly hidden by ANSI sequence, anybody have idea how to avoid this behaviour?