Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help! How to convert this Batch into VBS?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62025
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
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!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help! How to convert this Batch into VBS? - 6/30/2008 5:14:50 PM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
Sorry! I'm new to here.
Now I have a Batch and I want to convert it into VBS, please help!

      
 
 
Post #: 1
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 6:49:30 PM   
  djredmar


Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
Well,

What does the batch file do exactly?

(in reply to fastrun)
 
 
Post #: 2
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 7:14:46 PM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
quote:

ORIGINAL: djredmar

Well,

What does the batch file do exactly?


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.

(in reply to djredmar)
 
 
Post #: 3
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 7:25:21 PM   
  djredmar


Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
I  will write the code later;

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 >

(in reply to fastrun)
 
 
Post #: 4
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 7:39:05 PM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
quote:

ORIGINAL: djredmar

I  will write the code later;

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)?

(in reply to djredmar)
 
 
Post #: 5
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 7:51:29 PM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
quote:

ORIGINAL: djredmar

edit2:

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).

quote:


edit:
this does work :\

      

You are master!

(in reply to djredmar)
 
 
Post #: 6
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 7:56:59 PM   
  djredmar


Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
rar.exe will display the console :) (still black window)

Else u have to use winrar.exe (in code)

still need the code anyway?

(in reply to fastrun)
 
 
Post #: 7
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 8:05:52 PM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
quote:

ORIGINAL: djredmar

rar.exe will display the console :) (still black window)

Else u have to use winrar.exe (in code)

still need the code anyway?

If convenient, please. Thank you!

(in reply to djredmar)
 
 
Post #: 8
 
 RE: Help! How to convert this Batch into VBS? - 6/30/2008 9:47:29 PM   
  djredmar


Posts: 61
Score: 0
Joined: 12/11/2006
From: Europe, The Netherlands
Status: offline
Code got bigger than expected (i did want to use this later myself to)
Folders are working to! :-)

here it is:)

File:fastrun.vbs

      

(in reply to fastrun)
 
 
Post #: 9
 
 RE: Help! How to convert this Batch into VBS? - 7/1/2008 12:11:41 AM   
  fastrun

 

Posts: 6
Score: 0
Joined: 6/30/2008
Status: offline
quote:

ORIGINAL: djredmar

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.

      

myext.txt:
quote:


emeditor.exe .txt .reg .nfo .bat 
slowview.exe .jpg .png .gif .bmp
pe.exe .exe .dll


some explanations:

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. 


(in reply to djredmar)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help! How to convert this Batch into VBS? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts