| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed May 14, 2008 9:31 am Post subject: |
|
|
| System.Diagnostics.Process.Start()?
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed May 14, 2008 10:01 am Post subject: |
|
|
not exactly what i ment
i ment i wanna send a command to the command prompt like shutdown -s and stuff..
in vb what i did is Shell("shutdown -s") and it worked
_________________
Stylo |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Wed May 14, 2008 12:13 pm Post subject: |
|
|
| Shutdown is a system file, when you open it with the parameter "s" it shutdown windows.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed May 14, 2008 12:49 pm Post subject: |
|
|
i didnt mean just shutdown, i ment any other command that i can write in cmd..
_________________
Stylo |
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed May 14, 2008 12:54 pm Post subject: |
|
|
I think it's the same as c/c++:
etc
_________________
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed May 14, 2008 1:00 pm Post subject: |
|
|
| HalfPrime wrote: | I think it's the same as c/c++:
etc |
no it's not same as c++ :\
edit: i think i confused a little bit XD i think i missed the part that says that
shell keyword is only for executable files my bad ><"
but is any other way to write to the command prompt? like "cd ..." "md ..."
_________________
Stylo |
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed May 14, 2008 2:37 pm Post subject: |
|
|
oh thx that's what i wanted :]
_________________
Stylo |
|
| Back to top |
|
 |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Wed May 14, 2008 9:18 pm Post subject: |
|
|
| Code: | | Process.Start("cmd", "/C shutdown -s"); |
And just checked the URL above, which is essentially the same thing.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed May 14, 2008 9:57 pm Post subject: |
|
|
thx it's working now very greatful :]
another question please.. :] how can i run a few command as one for example:
| Code: |
cd c:\program files
md newFolder
|
cuz if i'll do it like this
| Code: |
Process.Start("cmd.exe","/c cd c:\program files");
Process.Start("cmd.exe","/c md newfolder");
|
it'll will create a new folder at the same place of the application
_________________
Stylo |
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Thu May 15, 2008 4:37 am Post subject: |
|
|
| Wouldn't it be better and faster to use the CreateFile function for that instead of all the shell and cmd stuff?
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Thu May 15, 2008 4:56 am Post subject: |
|
|
that's what i wanna save..
the file creation
my code create a .bat file with all my commands
and then i execute it but i dont want that..
i want to send the command right to the cmd instead writing it on a file
_________________
Stylo |
|
| Back to top |
|
 |
Estx Expert Cheater
Reputation: 0
Joined: 04 Mar 2008 Posts: 172
|
Posted: Thu May 15, 2008 6:46 am Post subject: |
|
|
There is already a framework for what you're trying to achieve.
| Code: | | System.IO.Directory.CreateDirectory(@"c:\program files\newfolder"); |
The '@' before the string makes the string literal.
| Quote: | Process.Start("cmd.exe","/c cd c:\program files");
Process.Start("cmd.exe","/c md newfolder"); |
You're starting two separate processes, meaning the directory wont be static between them.
If you're going to use the Process.Start() method for creating a directory, do the following:
| Code: | | Process.Start("cmd", @"/c md c:\program files\newfolder"); |
If you want, post up the batch file contents and I'll write up the code for it's equivalent in C#, then you can learn from that by reading and understanding what each line does.
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Thu May 15, 2008 7:33 am Post subject: |
|
|
my batch file include this code:
| Code: |
cd c:\tasm\bin
tasm /zi <filename>
tlink /v <filename>
td <filename>
|
as you can see my batch file compiles an assembly code to his .exe format using the Turbo Assembler 5.1 compiler...
so what i say is i wont be able to do the code as you show me on your example
| Code: |
Process.Start("cmd", @"/c md c:\program files\newfolder");
|
it'll be impossible since cmd wont be familiar with "tasm" keyword on any location
only in the TASM\BIN location this keyword will be able to use
_________________
Stylo |
|
| Back to top |
|
 |
|