Jump to content
Sign in to follow this  
faldo

Adding switches to console apps

Recommended Posts

faldo

I've been searching for an hour now without finding an answer, it may be due to my lack of knowledge of correct words.

Anyway, my question is if there's any way to create a script, compile it as console and send switches to to the script as variables.

ie.

The script called "addfolders.exe":

For $i = 1 to $Switch
  DirCreate ( "c:\temp\FolderNr"&$i)
next

In CMD i want to type...

addfolders.exe /10

...to create 10 folders in that given directory.

Edited by faldo

Share this post


Link to post
Share on other sites
faldo

erhm... i'm not sure what you mean by showing me that you need to add quotes to a commandline with spaces...

I need a similar function to ConsoleRead() but instead of typing:

echo Hello! | ConsoleRead.exe

i want to be able to type:

ConsoleRead.exe /Hello!

...and get switch piped down to stdin somehow... i'm not that good at how it works :/

Share this post


Link to post
Share on other sites
faldo

Never mind, problem solved... $CmdLine is the variable to use... thanx somdcomputerguy

For those who need it, the script would look like this:

For $i = 1 to $CmdLineRaw
  DirCreate ( "c:\temp\FolderNr"&$i)
next
[

and CMD command would be

ScriptName.exe 10

...to create 10 folders.

Cheers!

Edited by faldo

Share this post


Link to post
Share on other sites
somdcomputerguy

I'm glad you got it going. I'm not too good with words, so I'm glad that my cryptic post of just a link was good enough to help you.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×