edit the etc\hosts file - c

Using C or a bat file, I'm trying to edit the file hosts file from c:\Windows\System32\drivers\etc but I can;t bc it is write protected.
Can you tell me what can i do?

The program modifying the host file needs to run as Administrator

Can you tell me what can i do?
Yes. Get the Administrator password or find another way to solve your problem.
If you describe what is your problem (rather than your issue on a possible solution) maybe we can figure a different (working) solution.

Open the file from VS code. VS code it self will show a dialog box. Confirm it.

Related

How to open a very long link from batch

I write to you because I should create a small batch file to open a very long link containing symbols including &.
At the moment I'm trying to use the following structure:
explorer "www.mylink.com etc"
But not all the link is opened but it is truncated in half and therefore the server gives me an error reply.
Do you have any ideas on how to solve the problem?
I point out that I cannot shorten the link via a third party site as it contains confidential information.
Thank you in advance for your support. I'm sure it will be a very simple thing for those who are familiar with the language.
thanks for your feedback. It was easier then i thought, it worked in this way (i always need to open the link from Internet Explorer):
start iexplore.exe "https://myurl.com/etc%%etc7"

How to find a script that modifies a file on startup

I am currently on a machine where i have to change an existing script.
Nobody knows what path are.
I only know that modifies a file at startup , and it expects to have internet to do.
I try to find it with lsof but it looks like it is not enough "fast". It shows me nothing. I try to do with wireshark if he would send something, but nothing too.
I try to search with grep but nothing conclusive.
The machine is under OpenSuse x64 and i can be root.
Anyone have a solution for me? Thank you in advance.
Rc files or profile files are used to run commands on startup(depending on login or non login shells). These could be Generally in /etc - global and in home directory for user specific setting.
Have your considered checking contents of /etc/bashrc or /etc/bash.bashrc or profile? What did you grep for?

C - How can get file by window explorer (console)

I'm looking for function that open window explorer and get file the user selected. I knew how to open window explorer to this my question, but I was asking the wrong question. I want to enable read to the user selects a file.
While trying to search, I found OpenFileDialog(). But this function looks like need GUI. Am I right? (My program runs only console)
How can I open windows explorer on the console and get the file from the user?
I'm a beginner of C. So my question may seem ridiculously easy. But if you give me the answer I really appreciate it. Thanks :)
You are looking for the GetOpenFileName function. (OpenFileDialog is for .NET applications; if you are using C then you are not using .NET).
According to MSDN, this has been superseded by the Common Item Dialog system, but that system is much more complicated, requires COM and isn't necessary if you are only selecting files. GetOpenFileName will still work for the foreseeable future.
To open Windows explorer:
system("start \"\" \"c:\\program files\"");
To open a specific file:
system("start \"\" \"c:\\program files\\file.txt\"");

Changing a .bat to a .jar

Sorry if this is a very simple solution, but I have searched and couldn't find an answer, and have limited programming experience. What I am trying to accomplish is making Minecraft download and run outside of %appdata% on windows. I would like it to download .minecraft to a separate folder and run from there. To accomplish this, I wrote a .bat file with this code:
set APPDATA=%CD%\data
bin\minecraft.exe
this worked PERFECTLY. The catch is, I have a friend's computer that I want to do the same on, which runs Ubuntu. Is there a way to write one .jar file that works exactly the same that would work for both windows and linux? Thank you in advance for the help :)
No, just write
#!/bin/sh
APPDATA=somewhereorother/data bin/minecraft
chmod +x it, and use that for Linux.

How can I connect to an FTP with C?

Well, I'm trying to do a simple script to check any updates in an application. To check this, the most simple way I found is to connect to the FTP (where have a file which says the last update) and compares X file with a Y file. If the Y file is outdated, the script should run an installer/updater. Can I do it with C? I mean, can I connect to an FTP using C?
I research but nothing helpful was found.
At least, why C? I actually don't know. Part cause it is the language that I have more affinity, part cause I think it's clean, I dunno. Just intuition. haha.
Hope I have been clear.
PS: Working on Windows.
Well, I found another way to do this with a Batch File. I'm connecting to the FTP using the script (ftp -s:commands.txt ip.ftp) and then I use a comparation to check the differences. The rest was simple. Thank you all.

Resources