Freitag, 17. Februar 2012
Donnerstag, 16. Februar 2012
Change Password For Current User - VbScript
ChangePasswordForCurrentUser.vbs
Const ADS_UF_PASSWD_CANT_CHANGE = 64
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oUserEnv = WshShell.Environment("PROCESS")
userID = oUserEnv("USERNAME")
If Not IsEmpty(userID) Then
Set oADsUser = GetObject("WinNT://ww-intern/" & userID)
WScript.Echo "UserFullName = " & oAdsUser.Get("FullName")
lUserFlags = oAdsUser.Get("userFlags")
If lUserFlags AND ADS_UF_PASSWD_CANT_CHANGE THEN
WScript.Echo "User darf Kennwort nicht ändern, das passende Recht wird jetzt gesetzt"
lUserFlags = lUserFlags Or ADS_UF_PASSWD_CANT_CHANGE
ELSE
Wscript.Echo "User darf Kennwort ändern"
lUserFlags = lUserFlags And Not ADS_UF_PASSWD_CANT_CHANGE
End If
oAdsUser.Put "userFlags", lUserFlags
strOldPwd = InputBox("Bitte geben Sie das aktuelle Passwort ein:","Altes Passwort eingeben")
strNewPwd = InputBox("Bitte geben Sie das neue Passwort ein:","Neues Passwort eingeben")
If strNewPwd <> "" Then
oADsUser.ChangePassword strOldPwd, strNewPwd
WScript.Echo "Das Passwort wurde geändert"
Else
WScript.Echo "Das Passwort darf nicht leer sein!"
End if
Else
WScript.Echo "UserID konnte nicht ermittelt werden!"
End If
jscript terminate process
var objProcess;
var colProcess;
var strComputer = ".";
var strProcessKill = "'calc.exe'"
var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
var colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " + strProcessKill )
var enumItems = new Enumerator(colProcess);
for (; !enumItems.atEnd(); enumItems.moveNext()) {
var objItem = enumItems.item();
objItem.Terminate()
WScript.Echo("fund" );
}
WScript.Echo("Just killed process " + strProcessKill + " on " + strComputer );
automation - jscript http client
Need do download a file via HTTP on a Windows-Server?
Here is a how-to.
I used the binary format in the sample. So that data are saved as they come.
A text-based version can also be usefull.
It is also possible to support defirent encodings e.g. UTF-8.
Detailed Informations can be found under:
http://msdn.microsoft.com/en-us/library/ms535874(v=vs.85).aspx
Here is a how-to.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", 'http://www.nikem.de/Willkommen_files/chart1.jpg', false);
xmlhttp.send(null);
var adTypeBinary = 1
var adSaveCreateOverWrite = 2
var BinaryStream = new ActiveXObject("ADODB.Stream");
//Specify stream type - we want To save binary data.
BinaryStream.Type = adTypeBinary
//Open the stream And write binary data To the object
BinaryStream.Open();
BinaryStream.Write(xmlhttp.responseBody);
//Save binary data To disk
BinaryStream.SaveToFile ("C:\chart1.jpg", adSaveCreateOverWrite);
WScript.Echo("Ready");
I used the binary format in the sample. So that data are saved as they come.
A text-based version can also be usefull.
It is also possible to support defirent encodings e.g. UTF-8.
Detailed Informations can be found under:
http://msdn.microsoft.com/en-us/library/ms535874(v=vs.85).aspx
Abonnieren
Posts (Atom)