Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Local Network Chatroom [Improved]

How do I have it that the shared folder is not live/linked? That's the only thing I need done currently, then I need to set permissions and actually make the script. How would the messages work? I'm looking at the code right now and it seems like it's using a log file to output stuff I think? I'm stuck though. Also how do I do this for school computers? No permissions :(
You almost certainly won't have permissions to create network shares on a school or work computer, unless you're part of the admin team.

The minimum required to get this working would be 2 Windows computers at home, which you have full control over.
Without at least that, you won't be able to effectively test whether the script is working.

Okay... sigh... here we go.
The basic idea with Network Shares is that you can designate some folder on your computer to be "shared" with other computers on the network.
So suppose Jim and Jane are both using computers on the same network.

Jim creates a folder in C: called C:\CatFolder and right-clicks on it, goes to Properties, and sets it up as a network share using the "Sharing" tab.
Jim then opens a command prompt and types ipconfig and notes the ipv4 address of the computer is 192.168.1.5

Jane then opens Windows Explorer (that's the thing you browse files and folders with, NOT Internet Explorer)
In the address bar, Jane types the following:
Code
\\192.168.1.5\
After a moment, the window changes to show a list of available Network Shares on the remote machine.
Jane sees only 1 network share; CatFolder
Jane goes into CatFolder and creates a text file, in the text file Jane writes "Hello" and saves it.

Jim goes into C:\CatFolder and finds a text file there, opens it and sees the text "Hello".

Now then. With that out the way, Ali, you already know how to use a batch file to send text to a text file.
And you already have a pretty good idea how to READ text from a text file.
So... can you see how this might work? :>
No, I don't see how this might work. Maybe use the CALL function or when the user inputs text it outputs it to a text file, then Batch reads it and then outputs it to the console?
Quote:when the user inputs text it outputs it to a text file, then Batch reads it and then outputs it to the console?


Yes, exactly that!

Here's another example:
A script running on Jim's computer sends the following text to a text file on the network share:

Code
Jim: Hi Jane!

Jane runs the script too, it looks in the network share and uses the type command to display it on the screen.
Now Jane sees what Jim wrote.

Do you understand now? :>
Yes, but how do I use the type command exactly?
(May 4, 2015 04:45 AM)'Palladium Wrote:  Yes, but how do I use the type command exactly?

Code
type textFile.txt

Try it. :>
(May 4, 2015 05:00 AM)HacksBro Wrote:  I tried it and it works, but is it possible that I can set it to a variable? For example. I have a text file called playerName then inside it is Ali or whatever. Then I do this command:
Code
@ECHO OFF
TYPE C:\Users\Ali\Desktop\playerName.txt
SET playerName=0
SET TYPE=%playerName%
Could I do something like that?

Couldn't I use a FOR /L instead of the command TYPE? Would it affect my script?

Also how do I make it that it automatically enables file sharing and file sharing on a certain folder? Thanks brother.

FOR /L loops over a range of numbers. TYPE displays the contents of a file. Both are compete unrelated.

Crez already gave you the code to share a folder.
(May 4, 2015 05:00 AM)HacksBro Wrote:  I tried it and it works, but is it possible that I can set it to a variable? For example. I have a text file called playerName then inside it is Ali or whatever. Then I do this command:
Code
@ECHO OFF
TYPE C:\Users\Ali\Desktop\playerName.txt
SET playerName=0
SET TYPE=%playerName%
Could I do something like that?

Couldn't I use a FOR /L instead of the command TYPE? Would it affect my script?

When you use the type command, it echoes a number of lines of text onto the screen - one line for each line in the text file. (Captain Obvious! But for clarity, I am stating this anyway)

If you want to process a bunch of lines of text and somehow extract a variable from it, the best method of doing that is with the for /f loop.

for /f is used to process some lines of text.

The text can be a text file, or the output from a command, or a single line of text that is specified manually.

So for example, suppose you had a text file that contains the following text:

chatLog.txt
Code
CHAT LOG
MSG Jane 10:13 Hi Jim!
END CHAT LOG

This shows an example chat log, from which the script would parse information.
Suppose we want to capture the name "Jane":

Code
for /f "tokens=1,2,3*" %%a in ('type chatLog.txt') do (if "%%a" == "MSG" set name=%%b)
echo %name%

That is going to split each line of text up into FOUR CHUNKS.
The chunks will be referred to as %%a, %%b, %%c and %%d.
Perhaps you wonder why "1,2,3*" means there will be 4 tokens. We only have numbers 1-3 after all.
The reason is the asterisk symbol at the end (*). This tells batch "just chuck everything else on the line into the next token".
This is useful for us because we can then have the message as the last thing to appear on the line, and it can have spaces in it, and they will not be treated as delimiters between tokens.

So lets walk through the process that the for /f loop will use.
It processes the first line, and splits up the text into chunks (or "tokens"):
%%a = CHAT
%%b = LOG
%%c =
%%d =

Now it checks if "CHAT" is equal to "MSG", and it isn't, so it does nothing.

OK, NEXT LINE!
%%a = MSG
%%b = Jane
%%c = 10:13
%%d = Hi Jim!

Once again, we check if "%%a" == "MSG"
That evaluates to if "MSG" == "MSG", and this time IT'S TRUE!!
So we then set a variable called %name% and the value is Jane.

Finally, we process the 3rd line.
%%a = END
%%b = CHAT
%%c = LOG
%%d =

We are therefore checking if "END" == "MSG" and that returns false, so it does nothing.

Done!
Now we echo %name% and sure enough, there is Jane. :>
(May 3, 2015 06:03 PM)Cyclee Wrote:  Really cool. Thank you for recreating this 🎉
Thank you! :) Means a lot!

@HacksBro I currently have not much time to make a tutorial explaining how it works. Maybe in 2 or 3 days. Sorry for that :-/
(May 4, 2015 02:54 AM)annikk.exe Wrote:  Jim creates a folder in C: called C:\CatFolder

Off topic, I like how you incorporate cats into just about everything.
(May 4, 2015 06:07 PM)Cyclee Wrote:  Off topic, I like how you incorporate cats into just about everything.

Annikk.exe is most definitely feline. It's kinda his shtick.
I've heard rumours WhiteLight might also actually be a cat. Unconfirmed though. :>
I think basically most people on these forums in reality are cats.
Thanks for the help once again.
(May 4, 2015 11:51 PM)annikk.exe Wrote:  I've heard rumours WhiteLight might also actually be a cat. Unconfirmed though. :>
I think basically most people on these forums in reality are cats.

Those rumours are baseless and unfounded.
(May 5, 2015 05:08 AM)White Light Wrote:  
(May 4, 2015 11:51 PM)annikk.exe Wrote:  I've heard rumours WhiteLight might also actually be a cat. Unconfirmed though. :>
I think basically most people on these forums in reality are cats.

Those rumours are baseless and unfounded.

Really? :> Are you sure you aren't a cat that just enjoys role-playing as a human? :>

::purr::


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Release] by Young GeorgeFeb 5, 2024 03:59 PM 9 322 Feb 5, 2024 03:59 PM
Last Post: Suspect.
[Shell] by samir50Sep 24, 2018 12:33 PM 3 262 Sep 24, 2018 12:33 PM
Last Post: ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™
[Shell] by White LightAug 25, 2016 07:06 AM 4 177 Aug 25, 2016 07:06 AM
Last Post: gogglebot