|
Answer» Hello all,
I am trying to create a batch file for windows 7 that will essentially change the permissions of a folder from a read-only to full control, execute some commands and then revert the folder BACK to read only. Any ideas???Why do you want to do this?
We are integrating with a company in california, and we are trying to make this as easy as possible for them to setup our software. So we need to modify the hosts file to let them connect to our ip address in order to use the software that we are providing. (its online based) If these ip addresses are not in there they cannot use our programs.So you are operating as a software professional and yet you need to ask on a forum such as this? No need to be a smart, I am not a software professional, and I never once said I was, I am entry level new guy here who just wanted to bounce off ideas. I am at the bottom of the totem pole given this task. If you don't have anything helpful then just ignore this post and move on. You can utilize the icacls command in dos to modify permissions in folders.
Try typing icacls /? at the command prompt for some information on the command. You are going to need admin privileges to modify any settings with the icacls command, so you will likely need to coordinate with the IT department in the other organization to help with that.
What you are describing here sounds like a fairly big project, and as far as suggestions go, I would start by suggesting you look into a different PROGRAMMING language than batch for this. There are a few reasons, but I'll give you two big ones up front.
1. Other programming languages offer a lot more flexible and better suited methods of accomplishing tasks. You can try VBScript for one suggestion, but if at all possible, try to steer clear of batch.
2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.
If, for whatever reason, you must use batch for this, then please let us know.So far, this thread has followed a fairly recognisable pattern:
OP: How can I overcome security settings to perform unspecified operations in an unspecified folder, and get out again, and make it all like it was before? Me: This is how you do it [hmmm... EDIT] Why do you want to do this? OP: I want to get in a system folder and modify a file directly concerned with security. I appear to think that I need to modify the HOSTS file so that a user can connect with an "IP address". Me: Given the nature of the task you wish to perform, how come you don't know how to do this already? (Implied: How come you don't have admin privileges?) OP: (Angrily) Don't get smart with me! If you won't help me, get lost!
EDIT: OK, so we now seem to have thrown caution to the winds... (rolls eyes)
I will look to alternate programming solutions......
Quote from: Raven19528 on October 26, 2011, 12:52:10 PM You can utilize the icacls command in dos to modify permissions in folders.
Try typing icacls /? at the command prompt for some information on the command. You are going to need admin privileges to modify any settings with the icacls command, so you will likely need to coordinate with the IT department in the other organization to help with that.
What you are describing here sounds like a fairly big project, and as far as suggestions go, I would start by suggesting you look into a different programming language than batch for this. There are a few reasons, but I'll give you two big ones up front.
1. Other programming languages offer a lot more flexible and better suited methods of accomplishing tasks. You can try VBScript for one suggestion, but if at all possible, try to steer clear of batch.
2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.
If, for whatever reason, you must use batch for this, then please let us know.
Thats the problem they dont have IT over there they have consultants and they pretty much dont want to do anything just click click and thats all. If it were me I would have canned them but I have to make due with what I am given. Now this is sort of what I got its rough but.......
echo off REM Used to create a backup of the original host file and copy in the new one icacls C:\Windows\System32\drivers\etc\ /t /e /g users:F REM Creating a backup of the original host file ren C:\Windows\System32\drivers\etc\hosts hostsbk REM Used on a XP machine xcopy "%USERPROFILE%\Desktop\Test\hosts" C:\Windows\System32\drivers\etc\ /y REM Used on a Windows 7 machine xcopy "%USERPROFILE%\Desktop\Test\hosts" C:\Windows\System32\drivers\etc\ /y Pause
Quote from: Salmon Trout on October 26, 2011, 12:52:34 PMI appear to think that I need to modify the HOSTS file so that a user can connect with an "IP address".
Okay, I think I need to understand a little better as to the reasoning behind this exact question. Why are you needing to modify the HOSTS file for an IP install?
Wouldn't the entire process be much easier if you were to create a program that downloaded the install file from the IP address and then ran the program as an administrator? My whole problem is that the whole situation just sounds... not right. If the consultants are all using company IT, there should be SOMEONE who has admin access to those machines. Or all of them do. Either way, modifying the HOSTS file seems a little too extreme of a security bypass to be taking for something that the other company should be willing to work with you on. Find out who has admin access, see if they can grant you an admin account to utilize on the computers, and then we can help you design a simple batch process to download and install the program.
Quote from: Raven19528 on October 26, 2011, 01:33:26 PMMy whole problem is that the whole situation just sounds... not right.
So I'm not the only one. Like I said, a recognisable pattern. This is just the sort of social-engineering method that would-be hackers use to get GEEKS to write their scripts for them. Or lazy employees use to get geeks to do their jobs for them. Or genuinely puzzled technically ignorant people trying to get a legitimate task performed. The trouble is, we can't tell which it is.
The program we use is online based or I guess can only be runned if on our network, it has a specific ip address but because of security here not anyone can access it unless their host file is given that particular IP address.
But nevermind I got it to work. Thanks
Quote from: Raven19528 on October 26, 2011, 12:52:10 PM2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.
Powershell definitely looks more professional... those curly brackets are really impressive.
Quote from: Salmon Trout on October 26, 2011, 01:47:02 PMthose curly brackets are really impressive.
I KNOW!! RIGHT!?! Raven...think before you leap...
I tend to side with Salmon on this one for sure...If software needs a modified HOSTS file to RUN, something is badly wrong.
|