Jump to content

Help Automating a few bits..


Recommended Posts

Right,

I need to add a domain security group to the local admin group on machines & i have been told we cannot do it through AD as it will knock out any other users that have been manually put into the odd machines local admin group.

How can I automate the process of adding a domain security group to the local admin group on install?

Also,

from the runonce i want the defragmenter "mmc dfrg.msc"

to open & run a defragmentation. how can i automate this with what switches to set it running.? I know this can run behind the scenes but i need this to run visually.

all help is greatly apreciated..

Edited by chiners_68
Link to comment
Share on other sites


I need to add a domain security group to the local admin group on machines & i have been told we cannot do it through AD as it will knock out any other users that have been manually put into the odd machines local admin group. How can I automate the process of adding a domain security group to the local admin group on install

Here's how I do it:

I have a file called Admins.cmd that contains the following code:

net localgroup "Administrators" /ADD "MFC\TN_DTS_WrkAdm"

It's saved in the $1\Installs folder on the CD. This is called by the following statement in RunOnce:

REG ADD %KEY%\075 /VE /D "Adding Administrators" /f

REG ADD %KEY%\075 /V 1 /D "%systemdrive%\install\admins.cmd" /f

Hope this helps!

Link to comment
Share on other sites

Here is a defrag script that runs hidden

Const Hidden = 0,Normal = 1,Min = 2
Const HD = 2
Dim Act, Fso, Drv
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Drv = Fso.Drives
For Each objDrv in Drv
If objDrv.DriveType = HD Then
Act.Run("Defrag.exe " & objDrv & "\ -F"),Hidden,True
End if
Next

Link to comment
Share on other sites

Thanks, here is one in Js Script this has a pop up that will tell you what drive it defragging

Save As Defrag.js

var Fso = new ActiveXObject("Scripting.FileSystemObject");
var Act = new ActiveXObject("Wscript.Shell");
var Drv, strDrv, s, Defrag, V; V = "\\"
Disk()
function Disk()
{for ( var objEnum = new Enumerator(Fso.drives);!objEnum.atEnd();objEnum.moveNext())
{Drv = objEnum.item()
if (Drv.IsReady) {if (Drv.DriveType == "2")
Defrag = Act.Popup ("Preparing To Defrag This Drive, " + Drv.Path +
V+'\n'+ "Volume Name : " +Drv.VolumeName ,5,"Temp Stop", 0 + 32);
Act.Run("Defrag.exe " +Drv.Path+V+ " -F",0,true);
}} return;}

Link to comment
Share on other sites

Right,

Im runnig this script for defragmenting.

var Fso = new ActiveXObject("Scripting.FileSystemObject");

var Act = new ActiveXObject("Wscript.Shell");

var Drv, strDrv, s, Defrag, V; V = "\\"

Disk()

function Disk()

{for ( var objEnum = new Enumerator(Fso.drives);!objEnum.atEnd();objEnum.moveNext())

{Drv = objEnum.item()

if (Drv.IsReady) {if (Drv.DriveType == "2")

Defrag = Act.Popup ("Preparing To Defrag This Drive, " + Drv.Path +

V+'\n'+ "Volume Name : " +Drv.VolumeName ,5,"Temp Stop", 0 + 32);

Act.Run("Defrag.exe " +Drv.Path+V+ " -F",0,true);

}} return;}

but it runs silently without a progress bar or anything..

Link to comment
Share on other sites

This uses the cmd interface to defrag so there is no progress bar I have set it so it sits min on the task bar.

Save As Defrag_Min.js

var Fso = new ActiveXObject("Scripting.FileSystemObject");
var Act = new ActiveXObject("Wscript.Shell");
var Drv, strDrv, s, Defrag, V; V = "\\"
Disk()
function Disk()
{for ( var objEnum = new Enumerator(Fso.drives);!objEnum.atEnd();objEnum.moveNext())
{Drv = objEnum.item()
if (Drv.IsReady) {if (Drv.DriveType == "2")
Defrag = Act.Popup ("Preparing To Defrag This Drive, " + Drv.Path +
V+'\n'+ "Volume Name : " +Drv.VolumeName ,5,"Temp Stop", 0 + 32);
Act.Run("Defrag.exe " +Drv.Path+V+ " -F",2,true);
}} return;}

Yhis makes it the max size

Save As Defrag_Max.js

var Fso = new ActiveXObject("Scripting.FileSystemObject");
var Act = new ActiveXObject("Wscript.Shell");
var Drv, strDrv, s, Defrag, V; V = "\\"
Disk()
function Disk()
{for ( var objEnum = new Enumerator(Fso.drives);!objEnum.atEnd();objEnum.moveNext())
{Drv = objEnum.item()
if (Drv.IsReady) {if (Drv.DriveType == "2")
Defrag = Act.Popup ("Preparing To Defrag This Drive, " + Drv.Path +
V+'\n'+ "Volume Name : " +Drv.VolumeName ,5,"Temp Stop", 0 + 32);
Act.Run("Defrag.exe " +Drv.Path+V+ " -F",1,true);
}} return;}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...