#21228 - 2002-05-06 06:12 PM
Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
Like many others I'm trying to modify the registy upon login to the domain.
the HKCU does fine, but the HKR/HKLM balk. I understand the reasons why, but the workaround using SU to call regedit has me at a loss.
What I'd like to do is have su call up regedit/kix and import to each machine the wanted entries as the local admin. (does the local admin have to have backup/restore privs too?)
So far my poking and prodding of su, regedit, kix, RTFM'ing have left me even more at a loss due to my complete lack of "programming 1337'ness".
Any help, clue or informative flaming, brow beating, links are appreciated.
|
|
Top
|
|
|
|
#21230 - 2002-05-06 10:42 PM
Re: Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
Ok, during the login script execution, I'd like to have su run regedit as the local admin.
So, according to the documentation the command should be something like this:
su admin "regedit /s entry.reg" .
I get varied errors; 2, 1722, 1385, 1326 and so forth.
I've tried full paths to the exe, reg entries and anything else I can think of...no dice except for getting notepad to run...yippie.
Did the kix install script, made sure the machine I was on was listed as the copy went thru...etc, etc.
Do I have to copy these files to the local machine first, then exec? (a la notepad working?)
Thanks
|
|
Top
|
|
|
|
#21231 - 2002-05-06 11:49 PM
Re: Not quite getting it.
|
FollowThisLogic
Fresh Scripter
Registered: 2002-05-03
Posts: 6
Loc: Jersey
|
Shouldn't you be able to add the appropriate reg entries using a Kix script? Even if regedit does work you'll still get the "update.reg has been entered into the registry successfully" window, and the user must click OK (an unnecessary annoyance for them).
Reg edits were what brought me to Kix in the first place...
What kind of entries are you putting into the registry anyway?
|
|
Top
|
|
|
|
#21232 - 2002-05-07 02:43 AM
Re: Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
Follow...
I'm trying to enter the "Dreaded" HKLM (local machine/Default user) which is normally protectd from editing...except in the case of admin users, naturally.
{pardon the blatant rip of my post to ARS}
You see "regedit /s " works *only* if the entry is in the HKCU (current user) and another context (that escapes me at the moment). (the /s is silent operation...don't want confirmation if it works, but will come up if it fails). The same rules apparently apply to kix's writevalue also. Grrrr.
At any rate, there is a super user utils (name "SU" of course) that will allow me to make a kix script/batch file and exec it on the local machine as an admin user...one problem: I can't get su to do what voodoo it should do.
Now I know that security wise it is rather stupid to have the bat/kix file stored in plain text..so when/if I get this working I'll do the kixcrypt thing.
The only thing I have not tried yet is to copy the reg files, exec files and all that to the machines (su is already deployed, as is suss the system service).
Grant you, it is prolly silly of me to try this as I have maybe 2 dozen or so workstation I admin, but, despite my lack of programming skills I want to learn this (kix/automation/better admin'ing) as it will help me in the future.
I suppose moving from C/C++ programming, to Hardware dude, to tech support to webmaster to sysadmin sort of proves the theory of entropy correct.
|
|
Top
|
|
|
|
#21235 - 2002-05-07 03:01 PM
Re: Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
sealeapord:
Is there a way to automate the workstation entry?
such as regedit /s \\@workstation\HKLM\some_entry or is doing what I trying to do only available manually or via the task scheduler?
|
|
Top
|
|
|
|
#21238 - 2002-05-07 03:40 PM
Re: Not quite getting it.
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
I fiddled around with the waitfor a little bit. The only problem with waitfor is you have to have a "handshake".
For example, suppose 5 PCs PC1 - PC5 send a:
waitfor -s script1
at the same time. The server-side script can only handle one of these, and the first one that responds will be the one handled. So, how do you know how long to wait for a server response?
Would it be something on the client side like:
code:
:installprog1 shell "waitfor -s prog1" shell "waitfor -t 3 @WKSTA" If @error <> "" goto installprog1 Else ? "Installing program 1. Please wait..." Shell "Waitfor @WKSTA" Endif
How do you know how long to make the timeout?
Brian
|
|
Top
|
|
|
|
#21241 - 2002-05-07 04:09 PM
Re: Not quite getting it.
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
So this would be using wkix32.exe? I didn't think kix32.exe would handle multiples... Also, how would you retreive the computer name from the waitfor command? Do you have to write the output to a file then read the file like this:
code:
break on :prog1 shell "%comspec% /c Waitfor prog1 > CPID.txt" $ok = open (1,"CPID.txt") $line = READLINE(1) $ok = Close (1) $computer = SUBSTR($line,23,LEN($line)-23) shell "%comspec% /c Waitfor -s " + $computer ? "Spawning process for " + $computer Run "wkix32.exe prog1schedtask.kix $cpname=" + $computer Goto Prog1
Would this work? Is there a better way?
Brian
(finally. after editing it a few times, it seems to work.. but how reliable is something like this going to be?) [ 07 May 2002, 16:27: Message edited by: BrianTX ]
|
|
Top
|
|
|
|
#21243 - 2002-05-07 05:13 PM
Re: Not quite getting it.
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
How about this?
Server-side:
code:
break on :prog1 shell "%comspec% /c Waitfor prog1 > CPID.txt" $ok = open (1,"CPID.txt") $line = READLINE(1) $ok = Close (1) $computer = SUBSTR($line,23,LEN($line)-23) shell "%comspec% /c Waitfor -s " + $computer ? "spawning sheduletask for " + $computer Run "wkix32.exe prog1.kix " + "$$computer=" + $computer Goto Prog1
prog1.kix
code:
shell 'jt.exe /sm \\' + $computer + ' /sj ApplicationName="\\server\share\VirusScan\setup.exe" Parameters="-s" /sc administrator password /saj prog1.job /rj /sd prog1.job' :testdone sleep 10 If READVALUE("HKLM\SOFTWARE\Network Associates\VirusScan","bVshieldEnabled") = 1 shell "%comspec% /c waitfor -s " + $computer Else Goto Testdone Endif
Client Side:
code:
:installprog1 shell "waitfor -s prog1" shell "waitfor -t 3 @WKSTA" If @error <> "" goto installprog1 Else ? "Installing McAfee VirusScan. This will take a few minutes. Please wait..." Shell "Waitfor @WKSTA" Endif
The main problem I see with this code is that I'm unsure how to detect if the installation is complete. I am trying to detect if VirusScan is running, however there should be a better way. Does anyone see any other problems with this code?
Brian (obviously more error checking needs to be done.. what if install fails? but.. i'm just trying to get a basic framework for now) [ 07 May 2002, 17:16: Message edited by: BrianTX ]
|
|
Top
|
|
|
|
#21244 - 2002-05-07 05:37 PM
Re: Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
LLigetfa:
Admittadly I am getting kind of lost in the discussion, but I'm getting bits that are rather informative and will prolly lead me to a solution.
I suppose I am leaning toward: Put all entries into one file. copy that reg file to the local box. exec su locally to enter the reg file get rid of the reg file.
If all of that works, then kixcrypt the files to at least keep the plain text passwords away from your average snooper.
I fairly sure I'm doing some of this stuff the hard way, for lack of an easier way (and one I can comprehend, too).
I'm going to keep at it and watch this thread for a better way {like the auto su installer}.
Moose
|
|
Top
|
|
|
|
#21245 - 2002-05-07 06:23 PM
Re: Not quite getting it.
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Moose,
I hope you don't think all my postings are extraneous info. Using task scheduler (jt.exe) to modify settings is a legitimate way of doing it. I don't like the idea of using SU or SUSS on client PCs because it poses security risks in and of itself.
If you look over the scripts I've written above, they are designed to use a segment of the logon script to activate a scheduled task on the PC. The reason I'm trying to synchronize with the logon script is because we have no way of knowing when PCs will be on. Also, the jt.exe (remote task scheduler) gets around all sorts of security problems.. Sealeopard has a LOT of great info on using it and my scripts are rudimentary (read simplistic) compared to what he's done.
Brian
|
|
Top
|
|
|
|
#21246 - 2002-05-07 08:13 PM
Re: Not quite getting it.
|
a_non_moose
Fresh Scripter
Registered: 2002-05-03
Posts: 17
Loc: UGA
|
BrianTX:
Not at all, dude. The task scheduler is quite a nice solution because the box/user is logged in and can run at an appropriate time.
I can't run or call SU from a UNC path or mapped drive so the way to do it seems like copy to pc, run from pc and get rid of those specific files.
But, as I've said...getting it to *work* manually before I automate it, and before I kixcrypt it would be the prudent thing to do.
So, manual -> batch -> kix script -> kix crypt'ed script.
Like the saying goes: "Tell me, and I'll forget. Show me and I might remember. Involve me and I'll never forget."
And to LLigetfa:
You are correct that the prudent thing to do is do the write to the registyr via kix, however it is under the same restrictions that regedit is. But, once again the issue is running it locally, vs running from a mapped drive or UNC path.
There is not urgency in what I'm doing, just curiosity and a desire to learn and make things easier in the process/future.
So, no big deal that I am still at step 2 and a half even after playing for less than a week's time.
(and stupidly enuf, I wonder if mapping L: to netlogon and doing a 'subst (drive letter) l:\scripts' will be a good enuf cheat to run the su command? Hummmm.
Thanks,
Moose
|
|
Top
|
|
|
|
#21247 - 2002-05-07 08:19 PM
Re: Not quite getting it.
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
I would copy the su.exe locally to the %windir% ... if you plan on using suss.exe, copy that to the %windir%\system32. Running that stuff by using a mapped drive doesn't sound like a great idea to me. Of course... the netlogon folder is already mapped to the Z: drive... so you could always try that.
Brian
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 584 anonymous users online.
|
|
|