![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 4
OS: WINDOWS VISTA
|
Can anyone help me create the following script?? I am new to VBScripting and need help. Need this for an assignment, can someone please help??
1. Your script must contains an opening comment that includes your name. 2. The script should have an associated configuration file that will terminate the script after 30 seconds. 3. This little script should display the message “I Require Parameters” if it is started without any command line parameters. 4. If there are parameters, generate the following message: Greetings, human. I found ? command line parameters. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Manager
Join Date: Sep 2004
Location: Colorado
Posts: 986
OS: Mac OS 9.1, Mac OS X 10.5.8, WinXP Pro, FreeBSD 6.0, Gentoo Linux
|
Re: vbscript-- parameters help!! PLEASE?????
We don't do homework - see the rules. If you have specific problems/questions related to that program someone might be able to answer them. We also generally like to see the source code, since it's hard to figure out a problem without seeing the source code.
__________________
![]() Has it been a few days since I replied to your thread? Don't panic! I'm a busy college student and may forget a post if I'm extra busy (or it might just take me a while to be able to do a decent reply). If you still need help and are awaiting my reply after a few days, PM me about it. When posting what errors you get, please give the full message. It makes helping you much easier. Last edited by shuuhen; 10-02-2008 at 01:42 PM. |
|
|
|
|
|
#3 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,879
OS: Vista, various linux distros
|
Re: vbscript-- parameters help!! PLEASE?????
Hey, as shuuhen says we don't give direct h/w etc.
You can find the VBScript User guide(from MSDN) here: http://msdn.microsoft.com/en-us/libr...7y(VS.85).aspx The fundementals section would help you through this assignment. If you have code you need help with then post it and we can help =](take a good stab at it first) Cheers, Jamey Last edited by jamiemac2005; 10-02-2008 at 04:05 PM. |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 4
OS: WINDOWS VISTA
|
Re: vbscript-- parameters help!! PLEASE?????
This is what i have come up with so far...
> 'Brian Fournier Assignment 1 > Dim WshShl > Set WshShl = WScript.CreateObject("WScript.Shell") > WshShl.Popup "I require Parameters" > > I don't know how to create a message that allows the user to > create parameters? > Can you possibly help? > > > The original assignment again was > > 1. Your script must contains an opening comment that includes > your name. > 2. The script should have an associated configuration file > that will > terminate the script after 30 seconds. > 3. This little script should display the message “I Require > Parameters” if it > is started without any command line parameters. > 4. If there are parameters, generate the following message: > Greetings, human. I found ? command line parameters. |
|
|
|
|
|
#5 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,879
OS: Vista, various linux distros
|
Re: vbscript-- parameters help!! PLEASE?????
Hey, by parameters it means command-line parameters... here's an article on using them in VBScript: http://www.devguru.com/Technologies/...Arguments.html
I think the idea of your origional assignment is if the count attribute of the Arguments collection(explained in the article above) is 0 then output the first message else output the second... Cheers, Jamey |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: Oct 2008
Posts: 4
OS: WINDOWS VISTA
|
'Brian Fournier --User command line parameters
Set objArgs = WScript.Arguments WScript.Echo WScript.Arguments.Count For Each strArg in objArgs WScript.Echo strArg if args.length= 0 then wscript.echo("I Require Parameters") else Wscript.echo("Greetings, human. I found " objArgs " command line parameters.") end if end if here is what i have so far and i cannot get the code to execute properly can anyone help.. please??? Thank you... This is for the 1st comment listed |
|
|
|
|
|
#7 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,879
OS: Vista, various linux distros
|
Re: vbscript-- parameters help!! PLEASE?????
Hey, i cleaned up your code =] it now works, run it from a command prompt with arguments and it works fine...
Code:
'Brian Fournier --User command line parameters
Set objArgs = WScript.Arguments
WScript.Echo objArgs.Count
For Each strArg in objArgs
WScript.Echo strArg
next
if objArgs.length= 0 then
wscript.echo("I Require Parameters")
else
Wscript.echo("Greetings, human. I found " & objArgs.Count & " command line parameters.")
end if
- line 5: the for statement has to be closed with a "Next" statement to make it only do the commands specified within the code bracket. - line 7: you used args rather than objArgs(simple wrong name) - line 10: when inserting a variable into a string you have to contagnate it(add it) with "&"s and i'm pretty sure you ment to write objArgs.Count there so i added it... - the last line had an extra end if statement that didn't need to be there(so it errored) Other notes: - you still had Wscript.arguments laying around after having defined objArgs, the script would still work fine as it was but it's better practice to use objArgs after that... As it is it was a Very good go at the assignment =], you just need to work on your syntax and you'll be fine.... cleaning it was nice and easy(because the logic was perfect behind it)... Cheers, Jamey |
|
|
|
![]() |
| Thread Tools | |
|
|