Solved

VB Script to ask for input where a file name would go

Posted on 2013-10-25
13
245 Views
Last Modified: 2013-11-18
My company is working on creating RSA tokens for Android.  In order to create the token we go through the whole process of creating from the server but then we have to download and convert the token using an application and command-line.  

I need assistance in creating a script that will allow me to enter the token name instead of having to type in the whole command everytime.

Command:

TokenConverter "FILENAME.sdtid" -android  -o tokenfile.txt

I would like the script to run this command but prompt for the Filename.sdtid so that it can be entered and then processed.

I'm new to scripting so I'm not even sure where to begin with this.

Any assistance would be appreciated.
0
Comment
Question by:MacGyver80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 2
  • 2
13 Comments
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39601395
Which OS is this? In Windows, you can create a small batch file, like this:

@echo off

TokenConverter "%1" -android  -o tokenfile.txt

Open in new window


That %1 gets replaced with the first parameter that gets passed to the batch file. So if you name the batch file mycvt.bat, your conversion command becomes:

mycnv FILENAME.sdtid

Open in new window

0
 
LVL 5

Author Comment

by:MacGyver80
ID: 39601441
It's Windows 7, so even a Powershell or VB would be helpful
0
 
LVL 5

Author Comment

by:MacGyver80
ID: 39601448
So I took the first script and made it in to a batch file, named it ConvertMyToken.bat.  Then, I took the 2nd and made it in to a bacth file and named it mycnv.bat.  I then launched the ConvertMyToken.bat and a command prompt appeared and then immediately closed.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 5

Author Comment

by:MacGyver80
ID: 39601481
This is what I started off using:

@echo off
c:\Token_Converter\TokenConverter TokenName.sdtid -android -o tokenfile.txt

But if I can get it to prompt for the token name instead of me having to put it in to the actual script every time it would save a lot of time.
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39601541
You don't have to put it in the script. My version uses %1, which gets replaced by the 1st parm from the command line. So this script:

TokenConverter "%1" -android  -o tokenfile.txt

Open in new window


when it is run like this:

mycnv FILENAME.sdtid

Open in new window


actually runs like this

TokenConverter "FILENAME.sdtid" -android  -o tokenfile.txt
0
 
LVL 5

Author Comment

by:MacGyver80
ID: 39601605
Forgive my lack of knowledge with scripting but I'm lost.  Are you saying all I have to put in to the batch file is

1: echo off
2:
3: TokenConverter "%1" -android -o tokenfile.txt

because it doesn't work.  It will open a the command prompt very quickly and then close without doing anything.
0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 500 total points
ID: 39636284
If you use the method shown by ThomasMcA2, you'll need to open a command prompt, change to the folder the script and files are, and type the line
   mycnv FILENAME.sdtid
Of course you can also hard-code paths to script and files, if you want to have them in different folders.

However, as I read it, you want to click on the script, and have it ask for the filename:
@echo off
set /p sdtid=Please provide filename without extension
TokenConvert %sdtid%.sdtid -android -o tokenfile.txt

Open in new window

You could also use that to create differently named output files:
@echo off
set /p sdtid=Please provide filename without extension
TokenConvert %sdtid%.sdtid -android -o %sdtid%.txt

Open in new window

You can also hard-code the paths to TokenConvert and/or the files again.
0
 
LVL 5

Accepted Solution

by:
MacGyver80 earned 0 total points
ID: 39642483
I actually wanted it to be a VBS but ended up going with a batch file.  Pretty much did some major searching on the web and came up with the following:

@echo off
set /p TokenName=Enter Token path and name or Drag token in to this window:
set /p User=Enter Username:
set /p Password=Enter Token Password Specified for Token in RSA:
T:\IT\IT-Installation\RSA_TokenConverter_Droid\TokenConverterFiles_DO_NOT_TOUCH\TokenConverter %TokenName% -p %Password% -android -o T:\IT\IT-Installation\RSA_TokenConverter_Droid\TokenURLs\%User%.txt
echo Creating and opening Token Output for %User%
echo Output location T:\IT\IT-Installation\RSA_TokenConverter_Droid\TokenURLs\%User%.txt
echo Token URL is being displayed. Close text file, then close this window...
echo **Note** When this window is closed the text file with the URL will be deleted...
T:\IT\IT-Installation\RSA_TokenConverter_Droid\TokenURLs\%User%.txt
pause
del T:\IT\IT-Installation\RSA_TokenConverter_Droid\TokenURLs\%User%.txt
0
 
LVL 5

Author Comment

by:MacGyver80
ID: 39643099
I've requested that this question be closed as follows:

Accepted answer: 0 points for MacGyver80's comment #a39642483

for the following reason:

I found the information myself and compiled the bat file in to an .EXE
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39643100
Objection:
Your posted solution might be what you used in the end, but never asked for. The similarity to what I've posted (and my posted being a direct response to your request as defined last), I cannot accept your final disposition. We can't help you with something you don't tell us, and what you have got was the best we could do under that circumstances.
0
 
LVL 5

Author Comment

by:MacGyver80
ID: 39644393
I've requested that this question be deleted for the following reason:

Found the answer myself through web searching
0
 
LVL 5

Author Closing Comment

by:MacGyver80
ID: 39656002
Thanks for the suggestions Qlemo. I was able to expand very much based off of that.
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question