Create a vbs file with a batch script

Solved
TheGBB Posted messages 12 Status Membre -  
 Anonymous user -

Hello,

I am trying to create a rcs.vbs script with this batch script:

 @echo off cls (Dim Shell, DesktopPath, INK Set Shell = CreateObject("WScript.Shell") DesktopPath = Shell.SpecialFolders("Desktop") Set Ink = Shell.CreateShortcut(DesktopPath & "\Vlc.LNK") Ink.TargetPath = "C:\Program Files\VideoLAN\VLC\vlc.exe" Ink.Save)>>rcs.vbs 

but I end up with an empty "rcs.vbs" script that does nothing.

I think the VBS script written is likely stopping the current batch command

whereas I want a "rcs.vbs" script that contains this code:

 Dim Shell, DesktopPath, INK Set Shell = CreateObject("WScript.Shell") DesktopPath = Shell.SpecialFolders("Desktop") Set Ink = Shell.CreateShortcut(DesktopPath & "\Vlc.LNK") Ink.TargetPath = "C:\Program Files\VideoLAN\VLC\vlc.exe" Ink.Save

3 réponses

barnabe0057 Posted messages 14431 Registration date   Status Contributeur Last intervention   4 929
 

Hello,

To send these lines into the file, you need to add ECHO in front of each VBS command:

 @echo off cls (echo Dim Shell, DesktopPath, INK echo Set Shell = CreateObject("WScript.Shell") echo DesktopPath = Shell.SpecialFolders("Desktop") echo Set Ink = Shell.CreateShortcut(DesktopPath & "\Vlc.LNK") echo Ink.TargetPath = "C:\Program Files\VideoLAN\VLC\vlc.exe" echo Ink.Save)>rcs.vbs

-

If the goal is to create a shortcut on the desktop, it’s easier to do it directly in batch:

 mklink "%USERPROFILE%\Desktop\Vlc.lnk" "C:\Program Files\VideoLAN\VLC\vlc.exe"


1
TheGBB Posted messages 12 Status Membre
 

Thank you so much, it works very well.

0
brucine Posted messages 24501 Registration date   Status Membre Last intervention   4 115
 

Hello,

I didn't understand anything (and I don't understand anything about vbs either, but that's not the question).

If we want a hybrid vbs/Batch script, we need to call the appropriate interpreter (cscript, wscript...) from the Batch.

If it's about creating a vbs script from scratch, a text editor is sufficient.

But assuming for one reason or another that we want to create such a script from a batch, we cannot redirect with >> a command that doesn't work in a batch: we need to use an ECHO command before the redirection.

0
Anonymous user
 

Hello TheGBB


When Brucine (whom I greet) says that he doesn't understand anything about VBS, it's not a criticism from him but just a fact; he codes very well in other languages (including bash) but not in VBS.

However, the rest of his response is a starting point for you: to execute the script, you need to use the right command and >> won't work.

In short, he is helping you, so yes, he isn't doing all the work for you, but that's the basic concept of this forum: to give leads, to make the requester think because we always remember better what we understand than what we've simply read.


Barnabé (whom I greet as well) kindly chews up the task for you, which is beneficial to you in the short term since you immediately have 2 exploitable solutions. But no matter what, to progress you will have to think for yourself and not expect the forum to provide you with a ready-made solution.

And it's great that you thank him, but the -1 for Brucine is in no way justified and that's why I am canceling it.


When I was little, the Dead Sea was only sick.
George Burns

0
brucine Posted messages 24501 Registration date   Status Membre Last intervention   4 115
 

Hello,

What importance, I indeed summarized the same thing as the first part of Barnabé's response, but you know, for me, "medals" are just above me...

0
barnabe0057 Posted messages 14431 Registration date   Status Contributeur Last intervention   4 929
 

I didn't understand the -1 either, so I upvoted to set things right.

0
Anonymous user
 

That TheBGG doesn't award you a "medal" through a +1 is one thing, but that it imposes an unjustified "sentence" is another.

  • a troll
  • an off-topic reply
  • a counterproductive response

This deserves a -1, a point worth exploring, doesn't it?

CCM is a support forum, not a social network where a pseudo-summary justice is applied with impunity.

If TheBGG wants to continue receiving help for free, it must respect the help it receives voluntarily.

That is the point of my intervention.

0