Jump to content

Adding switches to console apps


 Share

Recommended Posts

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
Link to comment
Share on other sites

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 :/

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...