All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help! How to convert this Batch into VBS? Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Sorry I forgot to give any description. Usually, we can use the command-line version winRAR to compress a file or folder into a RAR file, but you have to specify the absolute name and path for the destination compressed file, just like: start "" "c:\Program Files\WinRAR\WinRAR.exe" a -ep D:\test.rar %1
Now if you drag and drop a file to my batch above, it will compress the current file in to a compressed RAR file with the name(without extension name) and path of the source file itself. In Batch, %~n1 refers to the name of %1, and %~p1 refers the path of %1.
I don't like the black console window of CMD, so I'd like to convert it into VBS.
But there is an shell extension in the context menu of the file? (add to file.rar)
edit:
tested... but will you use rar.exe (console) or winrar.exe (gui) ?
If you remove your start from the beginning of the row, there will be no console window displayed ?
edit2:
Batch not working; tried several path's and drives, but driveletter not recognized:??
Summary: You want to drag an file and drop it into the .vbs file. This will start rar.exe and create an archive on the same path from the "file" you dropped?
edit: this does work :\
< Message edited by djredmar -- 6/30/2008 7:41:18 PM >
But there is an shell extension in the context menu of the file? (add to file.rar)
edit:
tested... but will you use rar.exe (console) or winrar.exe (gui) ?
If you remove your start from the beginning of the row, there will be no console window displayed ?
Thank you. I use a hotkey tool to start it instead of shell extension. Currently, I don't know the accurate difference between with rar.exe and winrar.exe. Will there be a black window if I use the console rar.exe? Or will there be a ProgressBar with the winrar.exe(gui)?
Batch not working; tried several path's and drives, but driveletter not recognized:??
Sorry, I just tested it in the same directory of the batch.
quote:
Summary: You want to drag an file and drop it into the .vbs file. This will start rar.exe and create an archive on the same path from the "file" you dropped?
Yes, I just use a hotkey tool to deal with it, and I think it's the same with drag and drop.
quote:
This will start rar.exe and create an archive on the same path from the "file" you dropped?
That's just what I wish to. The same path and same name(without extension name).
Code got bigger than expected (i did want to use this later myself to) Folders are working to! :-)
here it is:)
File:fastrun.vbs
Great! it's works well for me! Thank you so much!
BTW, I feel that this VBS could get the extension name too, (sorry, I don't know VBS, just a feeling) and there is another bat, which is used by me to open different file(files) by their extension name(s) ( I use it will a hotkey tool too). Maybe you will be interested.
Once you open the current file with this bat (drag&drop a file or folder to this bat or just use a hotkey like me), it will creat a temporary file selpop.txt by its extension name, and there are 3 possibilities: 1.If the current selected is a folder or a directory, it will start x.exe to open %1, 2.If not, and if the extension name exists in myext.txt(like .txt or .jpg or something else), it will open current file by its extension name with matching application at the begining of the row. 3.If the current selected is a file, and its extension name doesn't exist in myext.txt( this could often happen), it will open current file with x.exe.
I think this batch is very useful, because you often have to open the same file(s) with different applications(no software is universal), and the Windows Registry does not allow you to assoicate a file with many different applications. Maybe you will say, I can use "send to" of content menu to do it, but it's not portable,right? What's more, sometimes it's forbidden to modify the computer settings ( like our company), or even forbidden to access these "special Windows directories".
Yet I feel this Batch is not perfect yet. Because: 1.It will creat a temporary file, whicn is not very green; 2.if a folder contains a symbol "." , it will be treated as a file too. However, I don't know how to improve it. SORRY! It far exceeds my ability.