Category Archives: Utils

Install printers

Many times we have the perennial problem in Active Directory environments that occasionally a user session on a machine that is not his usual, this causes without designated network printers to install printers, you can use this script:
one file instalar.bat that installs the printer, use the microsoft script prnmngr.vbs , first check that the printer is not connected in this case\\servidor\impressorared, if there is then installed on another call at the same script
Finally use the scriptdefprinter.vbs, establishing it as the default

 REM ***** Check and Install Copier*****
cscript prnmngr.vbs -l | find "Printer name \\servidor\impressorared"
IF ERRORLEVEL 1 ( cscript prnmngr.vbs -ac -p "\\servidor\impressorared"
echo "\\iocor\fax installed"
)
cscript defprinter.vbs \\servidor\impressorared

the script defprinter.vbs:

Option Explicit
dim objArgs
Set objArgs = WScript.Arguments
Dim objPrinter
Set objPrinter = CreateObject("WScript.Network")
objPrinter.SetDefaultPrinter objArgs(0)
' End of example VBScript
Facebooktwitterredditpinterestlinkedinmail

Read More ...

Automated users creation

This simple script (useful for workgroup environments), is useful for generating users have in a text file users.txt this file has the following 2 fields for each line are separated by commas: user, password, example would be this::
pepito,passworddepepito
jaimito,passworddejaimito
joselito,passworddejoselito
….
the script reads the file and generates the user adds them to the Administrators group and sets the password expiration to never.

' get local computer name
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("usuarios.txt", ForReading)
Do Until objTextFile.AtEndOfStream
  strNextLine = objTextFile.Readline
  arrServiceList = Split(strNextLine , ",")
  strAccount=arrServiceList(0)
  strPswd=arrServiceList(1)
  ' check if local account already exists
  intExists = 0
  Set colAccounts = GetObject("WinNT://" & strComputer & "")
  colAccounts.Filter = Array("user")
  For Each objUser In colAccounts
    If objUser.Name = strAccount Then
       intExists = 1
    End If
Next
If intExists = 0 Then
  ' create local user
  Set colAccounts = GetObject("WinNT://" & strComputer & "")
  Set objUser = colAccounts.Create("user", strAccount)
  ' set pswd
  objUser.SetPassword strPswd
  objUser.SetInfo
  ' set pswd never expires
  Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",User")
  objUserFlags = objUser.Get("UserFlags")
  objPasswordExpirationFlag = objUserFlags Or ADS_UF_DONT_EXPIRE_PASSWD
  objUser.Put "userFlags", objPasswordExpirationFlag
  objUser.SetInfo
  ' add to local admins group
  Set objGroup = GetObject("WinNT://" & strComputer & "/Administradores,group")
  Set objUser = GetObject("WinNT://" & strComputer & "/" & strAccount & ",user")
  objGroup.Add(objUser.ADsPath)
End If
Loop
Facebooktwitterredditpinterestlinkedinmail

Read More ...

eclipse regular expressions find replace

Hi Guys!

this is a sample of a mega replace using regular expressions in eclipse:

find: \(\) \{ return (.+)\;

replace: \(String $1\) \ { this.$1 = $1;

see in action

before:

public void setserie() { return serie; }

public void setlote() { return lote; }

public void setlocation() { return location; }

after:

public void setserie(String serie)  { this.serie = serie; }

public void setlote(String lote)  { this.lote = lote; }

public void setlocation(String location)  { this.location = location; }

Facebooktwitterredditpinterestlinkedinmail

Read More ...

List all ip address from one computer

Simple way To get all ip directions of one pc,

 On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 Set colItems = objWMIService.ExecQuery 	("Select * from Win32_NetworkAdapterConfiguration")
cadena=""
For Each objItem in colItems
	For Each strIPAddress in objItem.IPAddress
		cadena=cadena & " " & strIPAddress
	Next
Next
Wscript.Echo cadena
Facebooktwitterredditpinterestlinkedinmail

Read More ...

Sudoku Resolver

From my summer obsession towards the sudokus, born this simple sudoku solver, when there is a unique option, choose one at random, if it had not the solution returns to the previous situation and choose another path
There are many Sudoku solvers and much better, but I have with my deductions and my way of making the sadisfacción to know that works is priceless…
link for the download: sudokuresolver.zip
_Hei!needs .net framework 2.0 to run.
Screen capture:
sudoku resolver

Facebooktwitterredditpinterestlinkedinmail

Read More ...

Categories

Subscribe to my Newsletter




By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close