Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Question] Shell command at c#
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 8:35 am    Post subject: [Question] Shell command at c# Reply with quote

is it possible to use it in C#?
cuz i know that in VB i can and i did it...
but i cant find that command in Visual C# .. any help please? Confused

_________________
Stylo
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed May 14, 2008 9:31 am    Post subject: Reply with quote

System.Diagnostics.Process.Start()?
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 10:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Wed May 14, 2008 12:13 pm    Post subject: Reply with quote

Shutdown is a system file, when you open it with the parameter "s" it shutdown windows.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 12:49 pm    Post subject: Reply with quote

i didnt mean just shutdown, i ment any other command that i can write in cmd..
_________________
Stylo
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Wed May 14, 2008 12:54 pm    Post subject: Reply with quote

I think it's the same as c/c++:
Code:
system("PAUSE")

etc

_________________
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 1:00 pm    Post subject: Reply with quote

HalfPrime wrote:
I think it's the same as c/c++:
Code:
system("PAUSE")

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
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Wed May 14, 2008 1:14 pm    Post subject: Reply with quote

Try this:
http://www.codeproject.com/KB/cs/wincmdline.aspx
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 2:37 pm    Post subject: Reply with quote

oh thx that's what i wanted :]
_________________
Stylo
Back to top
View user's profile Send private message
Estx
Expert Cheater
Reputation: 0

Joined: 04 Mar 2008
Posts: 172

PostPosted: Wed May 14, 2008 9:18 pm    Post subject: Reply with quote

Code:
Process.Start("cmd", "/C shutdown -s");


And just checked the URL above, which is essentially the same thing.
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed May 14, 2008 9:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Thu May 15, 2008 4:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu May 15, 2008 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Estx
Expert Cheater
Reputation: 0

Joined: 04 Mar 2008
Posts: 172

PostPosted: Thu May 15, 2008 6:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu May 15, 2008 7:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites