Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Newbie needs help

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Newbie needs help
  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 >>
 Newbie needs help - 6/20/2008 6:12:19 AM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
I am new to VBScript.  Actually all this object stuff feels odd to me - I am used to procedural thinking in programming - Assembly, Fortran, Basic etc.  Because of this I still haven't gotten through the VBScripting book, but have run into a problem maybe someone could help me with.

I can execute the following from the Command prompt

"C:\Program Files\Axon Data\Axcrypt\1.6.4.1\Axcrypt.exe" -b 2 -e -k "password" -J VBAxcrypt.txt

and it works just fine.  Everything after "...Axcrypt.exe" are parameters that are passed to the program Axcrypt.  The problem is:

How can I do this from a vbscript?  Can I?

I've tried:

Set WshShl = WScript.CreateObject("WScript.Shell")
WshShl.Run "C:\Program Files\Axon Data\1.6.4.1\AxCrypt.exe" -b 2 -e -k "password" -J VBAxcrypt.txt

I name this VBTest.vbs

If from a command prompt I say CScript VBTest.vbs I get this error:

VBTest.vbs(2, 60) Microsoft VBScript compilation error: Expected end of statement

It looks like VBScript is trying to use those parameters for something else.

Thanks
Wes




 
 
Post #: 1
 
 RE: Newbie needs help - 6/20/2008 7:45:34 AM   
  dm_4ever


Posts: 2665
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
This is a frequently asked question...try

"""C:\Program Files\Axon Data\Axcrypt\1.6.4.1\Axcrypt.exe"" -b 2 -e -k ""password"" -J VBAxcrypt.txt"

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to FL geezer)
 
 
Post #: 2
 
 RE: Newbie needs help - 6/20/2008 10:31:23 AM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
Thanks dm_4ever

It works great!

I just saw it, tried it, and was flabbergasted when it worked!  I'm ready to try to go on from here.

Thanks again

Wes

(in reply to FL geezer)
 
 
Post #: 3
 
 RE: Newbie needs help - 6/20/2008 11:52:23 PM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
Can you tell me how the quotes are paired? I see there are 3 at the start, then doubles all the rest except a single at the end.  Is there a place where I can learn about this stuff?

Wes

(in reply to FL geezer)
 
 
Post #: 4
 
 RE: Newbie needs help - 6/21/2008 3:15:40 AM   
  dm_4ever


Posts: 2665
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
The reason for so many quotes is that VBScript will take anything within a pair of quotes as a literal string....when you have spaces and you need quotes to be part of that string then you have to add a few extra to get there.  So technically you could have written that same command in these ways

WScript.Echo """C:\Program Files\Axon Data\Axcrypt\1.6.4.1\Axcrypt.exe"" -b 2 -e -k ""password"" -J VBAxcrypt.txt"  
OR

WScript.Echo Chr(34) & "C:\Program Files\Axon Data\Axcrypt\1.6.4.1\Axcrypt.exe" & Chr(34) & " -b 2 -e -k " & Chr(34) & "password" & Chr(34) & " -J VBAxcrypt.txt"

OR
WScript.Echo AddQuotes("C:\Program Files\Axon Data\Axcrypt\1.6.4.1\Axcrypt.exe") & " -b 2 -e -k " & AddQuotes("password") & " -J VBAxcrypt.txt"

Function AddQuotes(strText)
   AddQuotes = Chr(34) & strText & Chr(34)
End Function

NOTE:  Chr(34) = "  

Also notice how I use WScript.Echo to check and verify the output is the same as what I am looking for.

Another trick I use is copy the command that works from the command line, paste into notepad, replace all " with two "", then add " to the front and the end, and then finally test it with a WScript.Echo

...now that I go over this little trick that works most of the time for me...maybe this would help


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to FL geezer)
 
 
Post #: 5
 
 RE: Newbie needs help - 6/23/2008 6:45:01 AM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
Thanks dm_4ever.  I think this has got me on the way.

Wes

(in reply to dm_4ever)
 
 
Post #: 6
 
 RE: Newbie needs help - 6/26/2008 6:55:03 AM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
Well, It did get me going pretty good.  I made a lot of progress but have run into another puzzle.  It seems to be involved with the use of the wildcard character "*".  When I use the statements:

objFSO.DeleteFile "C:\Documents and Settings\Wes\My Documents\WorkAreaforRealScript\UploadFilePrepArea\*.*"

or

objFSO.CopyFile "C:\Documents and Settings\Wes\My Documents\WorkAreaforRealScript\*.exe"

or even

objFSO.DeleteFile "C:\Documents and Settings\Wes\My Documents\WorkAreaforRealScript\*.exe"

They all act as I expect.  The * seems to work as the wildcard character.  However in the statement:

If objFSO.FileExists("C:\Documents and Settings\Wes\My Documents\WorkAreaforRealScript\*.exe")

I don't get the behavior I expect.  This statement is always analyzed as if there are no files with an .exe extension.  It acts as if it is looking only for the specific file "*.exe" which does not exist.  Am I doing something wrong here?  How can I check a folder to see if there are any .exe files in it?  (My problem started in the case of the program getting to the CopyFile statement when there was no .exe file in the folder.)


(in reply to FL geezer)
 
 
Post #: 7
 
 RE: Newbie needs help - 6/26/2008 10:21:06 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
You cannot use wildcards in fileexists.  One way to do this would be to use files collection and then check for the exe extension.  Here is the example from the WSH docs.



      

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to FL geezer)
 
 
Post #: 8
 
 RE: Newbie needs help - 6/27/2008 7:56:37 AM   
  FL geezer

 

Posts: 6
Score: 0
Joined: 6/20/2008
Status: offline
Mike,

Thank you.  I didn't think of that, but after seeing what you suggested I wondered why I didn't think of it myself. 
(I must be learning - I hope).

Wes

(in reply to mbouchard)
 
 
Post #: 9
 
 RE: Newbie needs help - 6/29/2008 10:39:32 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
You are welcome.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to FL geezer)
 
 
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 >> Newbie needs help 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