Discussion Locked

IP and Account batch files

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi all,

I am attempting to write a batch file to run after a machine has been reimaged to automatically add it to the SMS collection. However, the first problem is that this can only be done from my Domain Admin account (which is not used in normal course) so:

a) Can you (temporarily) log on via the DA account through the batch file script?

and

b) Is there any way that I can obtain the IP address of the PC and then place it into the batch file (perhaps as a variable), the subnet wouldn't be a problem?

Many Thanks for any help that anyone can provide

5 replies

by skitzizzy

You can, but it's not the safest way to go.

Under WinNT/2k you could write a net use part of the batch to map a drive using the DA credentials you need, then have the batch file reference that mapped drive rather than UNC.

The password would be scripted in plain text though, so it would need to be stored in a VERY secure location, which may defeat the purpose of the script.

Perhaps you create or use a "user" account to do the task. Give another account (say setsms) DA priveldges, writea logon.bat type script and script the required changes, set it for that account alone to make the necessary changes, log on using that account afrter the system has been rebuilt (you need to test it anyway), then log off afterwards and it's done :-)

I'm not sure about the IP query. In theory you'd need to script up an IPCONFIG type script, log it to a new file and use AWK or something to strip out the text not needed. Then reference that file in your batch file.

No doubt someone here knows a better way too.

Hope this helps some,

Andy

by beermonster

Hi,
You can use this to get your IP address -

for /F "tokens=2 delims=:" %A in ('ipconfig ^| find /I ^"IP Address^"') do set ip=%A

all on one line of course. You can access then access the ip via the %ip% variable. On the subject of the DA, I'm not quite sure what that account needs to do - map a drive, call a restricted process etc. Perhaps one way will be to set the autoadminlogon key before the image is created, using an account that has DA rights, and have your script in the runkey so that it runs on first login. The first thing the script could do is clear the autologon \ account detail registry keys before running the sms portion. it's not ideal but it would work. hope this helps...

This discussion is closed to new replies.