[Samba] Machine Startup Shutdown Scripts

ganapathy murali krishnan gmurali at cs.uchicago.edu
Fri Jun 6 17:59:32 GMT 2003


[ Read the recent posts to
"SUMMARY: [Samba] Samba asPDC with WinXP Clients -> headache" thread
first. Changed the subject line so this becomes a new thread.]

 >> Each machine is populated with a "local" startup and shutdown
 >> scripts, and the local Group Policy is modified to activate this.
 >
 >
 > Where do I find these settings in gpedit.msc?

Modifying local group policy
----------------------------
+ \Windows\System32\GroupPolicy\Machine\Scripts has the scripts
   in appropriate directory.
+ Put a copy of the script in \Windows\....\Scripts\Startup
+ gpedit.msc -> Local Computer Policy -> Computer Configuration
      -> Windows Settings -> Scripts (Startup/Shutdown) -> SOMETHING
+ The scripts directory may not exist unless you run gpedit.msc
   and navigate to above mentioned page.

> How do you mount IPC$ as non-priveleged user if the script runs as SYSTEM?
> 
See the script.

---- localstartup -----
@echo off
rem -- Get network privileges by posing as nobody
net use \\sambaserver\IPC$ password /USER:sambdaserver\guestuser
rem -- mount the netlogon share
net use S: \\sambaserver\netlogon password /USER:sambaserver\guestuser
rem -- and execute the script
call S:\startup.cmd
rem -- Change directory to local drive
%SYSTEMDRIVE%
rem -- unmount all network drives
net use S: /D /YES
net use * /D /YES
------- end of script -----

Same script with obvious changes becomes the shutdown script.

Is there a place where one can put Windows scripts useful to
samba administrators? If there isn't any some one should set it up.
Basically a contrib directory, which may/may not ship with Samba,
but these are windows scripts written with console based automation
in mind.

>> 3. Clear all windows print queues (through a VBScript)
> Could you send me a copy of this function?

------------ lprm.vbs ------------
Set objWMIService = GetObject("winmgmts:" _
     & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
     ("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
     objPrinter.CancelAllJobs()
     Wscript.Echo "Name: " & objPrinter.Name
Next
----------- end of script ----------

This should work. Not tested it yet.

One can use the WMIService to get lots of information. Most of the
/proc stuff is accessible through WMI. Just need to know what classes
they are called. All the pieces of info you mentioned is accessible
using the WMI interface. So all you need to do is to write a VBScript
or a Python Script to gather the info.

 > I would like to add the systeminformation which you can find in
 > Linux under /proc eg. CPU Type, RAM, NICs MAC address etc into my LDAP
 > and let it update itself

> 
>> I do not know enough about how group policies work. 
> 
> It is one file called gpedit.msc, which sits in some folder under 
> C:\WINDOWS. It will get updated on startup and every 90mins (Default) 
> There are reg keys to set this behavior. I found something on the web, 
> telling if you just substitute the file and restart, it will get loaded 
> on restart. so that would be something for the shutdown script to do.
> 

Which registry key is that? Is there any other way to force a reread of
gpedit.msc? Something along the lines of

rundll32.exe somedll,somefunction

If we can figure out which dll has the code for rereading the gpedit.msc
it would be great.

- Murali




More information about the samba mailing list