Skip to content

Instantly share code, notes, and snippets.

View viniciusmelocodes's full-sized avatar
:octocat:
Serving customers with high quality projects

Vinícius Melo viniciusmelocodes

:octocat:
Serving customers with high quality projects
  • Vinícius Melo
  • Brazil
View GitHub Profile
// Rodar processo como usuário
function WTSQueryUserToken(SessionId: ULONG; var phToken: THandle): BOOL; stdcall; external 'Wtsapi32.dll';
procedure executarApp(appName: string);
var
hToken: THandle;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
res: boolean;
begin
uses
ComObj, ActiveX, JwaWinbase, JwaWtsApi32;
{$R *.DFM}
procedure ServiceController(CtrlCode: DWORD); stdcall;
begin
ServiceExample.Controller(CtrlCode);
end;
@viniciusmelocodes
viniciusmelocodes / logoffUsuariosDesconectados.ps1
Created July 5, 2021 19:54
Faz logoff de todos usuários desconectados e salva mensagem de processo concluído. Rodar com privilégios de administrador.
# Logoff de usuários desconectados
# logoffUsuariosDesconectados.ps1
# Vinícius Lopes de Melo - 07/2021
# $>powershell.exe -noprofile -executionpolicy bypass -file C:\Temp\LogoffProgramado\logoffUsuariosDesconectados.ps1
#Requires -Version 2
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true, ValueFromPipelinebyPropertyName = $true)]
[string[]]$ComputerName = $env:COMPUTERNAME
)
@viniciusmelocodes
viniciusmelocodes / Powershell change wallpaper
Created July 15, 2021 02:07 — forked from s7ephen/Powershell change wallpaper
How to change the desktop wallpaper from powershell.
set-itemproperty -path "HKCU:Control Panel\Desktop" -name WallPaper -value accipiter.png
@viniciusmelocodes
viniciusmelocodes / lista_orgaos_emissores.html
Last active November 8, 2021 05:58
Lista de órgãos emissores do Brasil
<option value="ABNC">ABNC - Academia Brasileira de Neurocirurgia</option>
<option value="AGU">AGU - Advocacia-Geral da União</option>
<option value="ANAC">ANAC - Agência Nacional de Aviação Civil</option>
<option value="CAER">CAER - Clube de Aeronáutica</option>
<option value="CAU">CAU - Conselho de Arquitetura e Urbanismo</option>
<option value="CBM">CBM - Corpo de Bombeiro Militar</option>
<option value="CFA">CFA - Conselho Federal Administração</option>
<option value="CFB">CFB - Conselho Federal de Biblioteconomia</option>
<option value="CFBIO">CFBIO - Conselho Federal de Biologia</option>
<option value="CFBM">CFBM - Conselho Federal de Biomedicina</option>
function buildTree($array, $currentParent, $currLevel = 0, $prevLevel = -1) {
foreach ($array as $categoryId => $category) {
if ($currentParent == $category['parent_id']) {
if ($currLevel > $prevLevel) echo "<ol id='menutree'>";
if ($currLevel == $prevLevel) echo "</li>";
echo '<li> <label class="menu_label" for='.$categoryId.'>'.$category['name'].'</label><input type="checkbox" id='.$categoryId.' />';
if ($currLevel > $prevLevel) { $prevLevel = $currLevel; }
$currLevel++;
buildTree ($array, $categoryId, $currLevel, $prevLevel);
$currLevel--;
/*Connecting to Database tempdb*/
mysql_connect('localhost', 'root');
mysql_select_db('tempdb');
/*Executing the select query to fetch data from table tab_treeview*/
$sqlqry="SELECT * FROM tab_treeview";
$result=mysql_query($sqlqry);
/*Defining an array*/
$arrayCountry = array();
CREATE TABLE IF NOT EXISTS tab_treeview (
id int(12) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL,
title varchar(255) NOT NULL,
parent_id varchar(12) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7;
INSERT INTO tab_treeview (id, name, title, parent_id) VALUES
(1, 'Mumbai', 'The Film City', '3'),
#menutree li { list-style: none; }
li .menu_label + input[type=checkbox] { opacity: 0; }
li .menu_label { cursor: pointer; }
li .menu_label + input[type=checkbox] + ol > li { display: none; }
li .menu_label + input[type=checkbox]:checked + ol > li { display: block; }
@viniciusmelocodes
viniciusmelocodes / logoff_usuarios.ps1
Last active November 22, 2021 12:04
Logoff de usuário em PowerShell
quser | Select-Object -Skip 1 | ForEach-Object {
$id = ($_ -split ' +')[-5]
$sessioname = ($_ -split ' +')[-4]
# Apenas faz logoff dos usuários desconectados
if ($sessioname -eq 'Disco') {
#Write-Host $id
#Write-Host $sessioname
logoff $id
}