working on it ...

Filters

Explore Public Snippets

Sort by

Found 17k snippets matching: windows

    public by cghersi modified Jul 27, 2013  338434  1  6  0

    ASP.NET Performance monitors

    The following XML file can be used to create a new user defined Data Collector Set in the Performance Monitor Tool for Windows servers. It checks the most important performance counters for the right execution of ASP.NET Web applications. The performance counters taken into account are those reported in this article: http://mvolo.com/fix-the-3-hi
    <?xml version="1.0" encoding="UTF-16"?>
    <DataCollectorSet>
    	<Status>0</Status>
    	<Duration>600</Duration>
    	<Description>Genera un rapporto con informazioni dettagliate sullo stato delle risorse hardware locali, sui tempi di risposta del sistema e sui processi eseguiti nel computer locale. Tali informazioni consentono di identificare le possibili cause dei problemi di prestazioni. Per eseguire questo Insieme agenti di raccolta dati, è necessario essere almeno membri del gruppo Administrators locale o di un gruppo equivalente.</Description>
    	<DescriptionUnresolved>Genera un rapporto con informazioni dettagliate sullo stato delle risorse hardware locali, sui tempi di risposta del sistema e sui processi eseguiti nel computer locale. Tali informazioni consentono di identificare le possibili cause dei problemi di prestazioni. Per eseguire questo Insieme agenti di raccolta dati, è necessario essere almeno membri del gruppo Administrators locale o di un gruppo equivalente.</DescriptionUnresolved>
    	<DisplayName>
    	</DisplayName>
    	<DisplayNameUnresolved>
    	</DisplayNameUnresolved>
    	<SchedulesEnabled>-1</SchedulesEnabled>
    	<Keyword>CPU</Keyword>
    	<Keyword>Memory</Keyword>
    	<Keyword>Disk</Keyword>
    	<Keyword>Network</Keyword>
    	<Keyword>Performance</Keyword>
    	<LatestOutputLocation>C:\PerfLogs\Admin\ASP.NET\ZIOJ-PC_20130727-000002</LatestOutputLocation>
    	<Name>ASP.NET</Name>
    	<OutputLocation>C:\PerfLogs\Admin\ASP.NET\ZIOJ-PC_20130727-000003</OutputLocation>
    	<RootPath>%systemdrive%\PerfLogs\Admin\ASP.NET</RootPath>
    	<Segment>0</Segment>
    	<SegmentMaxDuration>0</SegmentMaxDuration>
    	<SegmentMaxSize>0</SegmentMaxSize>
    	<SerialNumber>3</SerialNumber>
    	<Server>
    	</Server>
    	<Subdirectory>
    	</Subdirectory>
    	<SubdirectoryFormat>3</SubdirectoryFormat>
    	<SubdirectoryFormatPattern>yyyyMMdd\-NNNNNN</SubdirectoryFormatPattern>
    	<Task>
    	</Task>
    	<TaskRunAsSelf>0</TaskRunAsSelf>
    	<TaskArguments>
    	</TaskArguments>
    	<TaskUserTextArguments>
    	</TaskUserTextArguments>
    	<UserAccount>SYSTEM</UserAccount>
    	<Security>O:BAG:S-1-5-21-2577573897-3235701343-559641010-513D:AI(A;;FA;;;SY)(A;;FA;;;BA)(A;;FR;;;LU)(A;;0x1301ff;;;S-1-5-80-2661322625-712705077-2999183737-3043590567-590698655)(A;ID;FA;;;SY)(A;ID;FA;;;BA)(A;ID;0x1200ab;;;LU)(A;ID;FR;;;AU)(A;ID;FR;;;LS)(A;ID;FR;;;NS)</Security>
    	<StopOnCompletion>0</StopOnCompletion>
    	<TraceDataCollector>
    		<DataCollectorType>1</DataCollectorType>
    		<Name>NT Kernel</Name>
    		<FileName>NtKernel</FileName>
    		<FileNameFormat>0</FileNameFormat>
    		<FileNameFormatPattern>
    		</FileNameFormatPattern>
    		<LogAppend>0</LogAppend>
    		<LogCircular>0</LogCircular>
    		<LogOverwrite>0</LogOverwrite>
    		<LatestOutputLocation>C:\PerfLogs\Admin\ASP.NET\ZIOJ-PC_20130727-000002\NtKernel.etl</LatestOutputLocation>
    		<Guid>{00000000-0000-0000-0000-000000000000}</Guid>
    		<BufferSize>64</BufferSize>
    		<BuffersLost>0</BuffersLost>
    		<BuffersWritten>0</BuffersWritten>
    		<ClockType>1</ClockType>
    		<EventsLost>0</EventsLost>
    		<ExtendedModes>0</ExtendedModes>
    		<FlushTimer>0</FlushTimer>
    		<FreeBuffers>0</FreeBuffers>
    		<MaximumBuffers>200</MaximumBuffers>
    		<MinimumBuffers>0</MinimumBuffers>
    		<NumberOfBuffers>0</NumberOfBuffers>
    		<PreallocateFile>0</PreallocateFile>
    		<ProcessMode>0</ProcessMode>
    		<RealTimeBuffersLost>0</RealTimeBuffersLost>
    		<SessionName>NT Kernel Logger</SessionName>
    		<SessionThreadId>0</SessionThreadId>
    		<StreamMode>1</StreamMode>
    		<TraceDataProvider>
    			<DisplayName>{9E814AAD-3204-11D2-9A82-006008A86939}</DisplayName>
    			<FilterEnabled>0</FilterEnabled>
    			<FilterType>0</FilterType>
    			<Level>
    				<Description>Gli eventi fino a questo livello sono attivati</Description>
    				<ValueMapType>1</ValueMapType>
    				<Value>0</Value>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x0</Value>
    				</ValueMapItem>
    			</Level>
    			<KeywordsAny>
    				<Description>Gli eventi con almeno una delle parole chiave specificate sono attivati</Description>
    				<ValueMapType>2</ValueMapType>
    				<Value>0x10303</Value>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x1</Value>
    				</ValueMapItem>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x2</Value>
    				</ValueMapItem>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x100</Value>
    				</ValueMapItem>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x200</Value>
    				</ValueMapItem>
    				<ValueMapItem>
    					<Key>
    					</Key>
    					<Description>
    					</Description>
    					<Enabled>-1</Enabled>
    					<Value>0x10000</Value>
    				</ValueMapItem>
    			</KeywordsAny>
    			<KeywordsAll>
    				<Description>Gli eventi con tutte le parole chiave specificate sono attivati</Description>
    				<ValueMapType>2</ValueMapType>
    				<Value>0x0</Value>
    			</KeywordsAll>
    			<Properties>
    				<Description>I campi dati aggiuntivi specificati verranno raccolti con ogni evento</Description>
    				<ValueMapType>2</ValueMapType>
    				<Value>0</Value>
    			</Properties>
    			<Guid>{9E814AAD-3204-11D2-9A82-006008A86939}</Guid>
    		</TraceDataProvider>
    	</TraceDataCollector>
    	<PerformanceCounterDataCollector>
    		<DataCollectorType>0</DataCollectorType>
    		<Name>Performance Counter</Name>
    		<FileName>Performance Counter</FileName>
    		<FileNameFormat>1</FileNameFormat>
    		<FileNameFormatPattern>yyyyMMdd</FileNameFormatPattern>
    		<LogAppend>-1</LogAppend>
    		<LogCircular>0</LogCircular>
    		<LogOverwrite>0</LogOverwrite>
    		<LatestOutputLocation>C:\PerfLogs\Admin\ASP.NET\ZIOJ-PC_20130727-000002\Performance Counter20130727.csv</LatestOutputLocation>
    		<DataSourceName>
    		</DataSourceName>
    		<SampleInterval>1</SampleInterval>
    		<SegmentMaxRecords>0</SegmentMaxRecords>
    		<LogFileFormat>0</LogFileFormat>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\% Managed Processor Time (estimated)</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Viewstate MAC Validation Failure</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors During Compilation</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors During Execution</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors During Preprocessing</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors Unhandled During Execution</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors Unhandled During Execution/Sec</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Audit Failure Events Raised</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Error Events Raised</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Error Events Raised/Sec</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Infrastructure Error Events Raised</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Infrastructure Error Events Raised/Sec</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Request Error Events Raised</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Request Error Events Raised/Sec</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors Total</Counter>
    		<Counter>\ASP.NET Apps v4.0.30319(__Total__)\Errors Total/Sec</Counter>
    		<Counter>\ASP.NET v4.0.30319\Error Events Raised</Counter>
    		<Counter>\ASP.NET v4.0.30319\Infrastructure Error Events Raised</Counter>
    		<Counter>\ASP.NET v4.0.30319\Request Error Events Raised</Counter>
    		<Counter>\.NET CLR Exceptions\*</Counter>
    		<Counter>\.NET CLR Memory(_Global_)\% Time in GC</Counter>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\% Tempo processore gestito (stimato)</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errore di convalida MAC ViewState</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errori di compilazione</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errori di esecuzione.</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errori di pre-elaborazione</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errori non gestiti durante l'esecuzione</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Errori non gestiti durante l'esecuzione/sec</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore di controllo generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore generati/sec</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore infrastruttura generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore infrastruttura generati/sec</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore richiesta generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Eventi errore richiesta generati/sec</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Totale errori</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET Apps v4.0.30319(__Total__)\Totale errori/sec</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET v4.0.30319\Eventi errore generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET v4.0.30319\Eventi errore infrastruttura generati</CounterDisplayName>
    		<CounterDisplayName>\ASP.NET v4.0.30319\Eventi errore richiesta generati</CounterDisplayName>
    		<CounterDisplayName>\Eccezioni CLR .NET\*</CounterDisplayName>
    		<CounterDisplayName>\Memoria CLR .NET(_Global_)\Percentuale tempo in GC</CounterDisplayName>
    	</PerformanceCounterDataCollector>
    	<DataManager>
    		<Enabled>-1</Enabled>
    		<CheckBeforeRunning>-1</CheckBeforeRunning>
    		<MinFreeDisk>200</MinFreeDisk>
    		<MaxSize>1024</MaxSize>
    		<MaxFolderCount>100</MaxFolderCount>
    		<ResourcePolicy>0</ResourcePolicy>
    		<ReportFileName>report.html</ReportFileName>
    		<RuleTargetFileName>report.xml</RuleTargetFileName>
    		<EventsFileName>
    		</EventsFileName>
    		<Rules>
    			<Logging level="15" file="rules.log">
    			</Logging>
    			<Import file="%systemroot%\pla\rules\Rules.System.Common.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.Summary.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.Performance.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.CPU.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.Network.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.Disk.xml">
    			</Import>
    			<Import file="%systemroot%\pla\rules\Rules.System.Memory.xml">
    			</Import>
    		</Rules>
    		<ReportSchema>
    			<Report name="systemPerformance" version="1" threshold="100">
    				<Import file="%systemroot%\pla\reports\Report.System.Common.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.Summary.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.Performance.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.CPU.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.Network.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.Disk.xml">
    				</Import>
    				<Import file="%systemroot%\pla\reports\Report.System.Memory.xml">
    				</Import>
    			</Report>
    		</ReportSchema>
    		<FolderAction>
    			<Size>0</Size>
    			<Age>1</Age>
    			<Actions>3</Actions>
    			<SendCabTo>
    			</SendCabTo>
    		</FolderAction>
    		<FolderAction>
    			<Size>0</Size>
    			<Age>56</Age>
    			<Actions>8</Actions>
    			<SendCabTo>
    			</SendCabTo>
    		</FolderAction>
    		<FolderAction>
    			<Size>0</Size>
    			<Age>168</Age>
    			<Actions>26</Actions>
    			<SendCabTo>
    			</SendCabTo>
    		</FolderAction>
    	</DataManager>
    	<Value name="PerformanceMonitorView" type="document">
    		<OBJECT ID="DISystemMonitor" CLASSID="CLSID:C4D2D8E0-D1DD-11CE-940F-008029004347">
    			<PARAM NAME="CounterCount" VALUE="4">
    			</PARAM>
    			<PARAM NAME="Counter00001.Path" VALUE="\Processor(_Total)\% Processor Time">
    			</PARAM>
    			<PARAM NAME="Counter00001.Color" VALUE="255">
    			</PARAM>
    			<PARAM NAME="Counter00001.Width" VALUE="2">
    			</PARAM>
    			<PARAM NAME="Counter00001.LineStyle" VALUE="0">
    			</PARAM>
    			<PARAM NAME="Counter00001.ScaleFactor" VALUE="0">
    			</PARAM>
    			<PARAM NAME="Counter00001.Show" VALUE="1">
    			</PARAM>
    			<PARAM NAME="Counter00001.Selected" VALUE="1">
    			</PARAM>
    			<PARAM NAME="Counter00002.Path" VALUE="\Memory\Pages/sec">
    			</PARAM>
    			<PARAM NAME="Counter00002.Color" VALUE="65280">
    			</PARAM>
    			<PARAM NAME="Counter00002.Width" VALUE="1">
    			</PARAM>
    			<PARAM NAME="Counter00003.Path" VALUE="\PhysicalDisk(_Total)\Avg. Disk sec/Read">
    			</PARAM>
    			<PARAM NAME="Counter00003.Color" VALUE="16711680">
    			</PARAM>
    			<PARAM NAME="Counter00003.Width" VALUE="1">
    			</PARAM>
    			<PARAM NAME="Counter00004.Path" VALUE="\PhysicalDisk(_Total)\Avg. Disk sec/Write">
    			</PARAM>
    			<PARAM NAME="Counter00004.Color" VALUE="55295">
    			</PARAM>
    			<PARAM NAME="Counter00004.Width" VALUE="1">
    			</PARAM>
    		</OBJECT>
    	</Value>
    </DataCollectorSet>
    

    public by RSrini modified Jun 17, 2015  237158  33  3  0

    Installing db-sample-schema in windows (https://github.com/oracle/db-sample-schemas)

    Installing db-sample-schema in windows (https://github.com/oracle/db-sample-schemas): db-sample-schemas
    https://github.com/oracle/db-sample-schemas
    
    download the zip file and extract to "D:\app\rsrini7\product\12.1.0\dbhome_1\demo\schema"
    
    here rsrini7 is my username. extract the zip file to the dir according to your installation.
    
    open command prompt as administrator
    d: enter
    cd D:\app\rsrini7\product\12.1.0\dbhome_1\demo\schema
    
    mkdir log
    
    perl -p -i.bak -e 's#__SUB__CWD__#'D:/app/rsrini7/product/12.1.0/dbhome_1/demo/schema/'#g' *.sql */*.sql */*.dat
    
    (to install perl and other unix related tools - install babun - rocking tool for windows users. i love this )
    
    edit mksample.sql and all '_main.sql' files and follow the below instructions
    
    this is required : http://www.dba-oracle.com/t_ora_65096_create_user_12c_without_c_prefix.htm
    
    1. in connect statement 
    	add at the end 'as sysdba'
    2. after the connect statement add the below line
    	alter session set "_oracle_script"=true;
    
    type in the command prompt : sqlplus enter
    connect oracle with sys as sysdba and enter
    type the dba-password 
    
    At final execute the below script from sql prompt
    	
    @?/demo/schema/mksample <dba-password> <dba-password> password password password password password password EXAMPLE TEMP D:/app/rsrini7/product/12.1.0/dbhome_1/demo/schema/log/
    
    replace <dba-password> with the actual dba password
    
    happy learning:)
    
    

    public by rsrini7 modified Jun 28, 2015  168533  0  3  0

    Install Ruby and DevKit for Windows to install GEMs with DevKit dependency

    Install Ruby and DevKit for Windows to install GEMs with DevKit dependency: ruby-devkit-gem-windows
    Download Ruby installer and install / 7zip file and extract from http://rubyinstaller.org/downloads/
    set the ruby bin directory available in the PATH variable.
    
    Based on 32 / 64 bit arch, download DevKit from http://rubyinstaller.org/downloads/
    Extract DevKit as RubyDevKit into your ruby installed directory (you can extract anywhere)
    
    CD RubyDevKit
    ruby dk.rb init
    ruby dk.rb install
    
    Now you can happily install gem with dev dependency
    
    Looking for Jekyll Portable for windows ?? then ::: https://github.com/madhur/PortableJekyll
    
    
    

    public by David Grayson modified Sep 30, 2015  144638  1  3  0

    Simple Windows C program that connects to a serial port and prints out events from it, such as ring signals.

    Simple Windows C program that connects to a serial port and prints out events from it, such as ring signals.: serial.c
    // Lots of code was copied from https://msdn.microsoft.com/en-us/library/ff802693.aspx#serial_topic3
    
    #include <assert.h>
    #include <windows.h>
    #include <stdio.h>
    #include <stdbool.h>
    
    void ReportStatusEvent(DWORD s)
    {
        if (s == EV_RING)
        {
            printf("ring\n");
        }
        else
        {
            printf("status = 0x%lx\n", s);
        }
    }
    
    int main(int argc, char ** argv)
    {
        if (argc < 2)
        {
            fprintf(stderr, "Need at least one argument to specify the COM port.\n");
            return 1;
        }
    
        HANDLE port = CreateFile(argv[1], GENERIC_READ | GENERIC_WRITE,
            0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
        if (port == INVALID_HANDLE_VALUE)
        {
            DWORD error = GetLastError();
            fprintf(stderr, "Could not open port.  Error 0x%lx.\n", error);
            return 1;
        }
    
        DWORD flags = EV_BREAK | EV_CTS | EV_DSR | EV_ERR | EV_RING |
            EV_RLSD | EV_RXCHAR | EV_RXFLAG | EV_TXEMPTY;
        BOOL success = SetCommMask(port, flags);
        if (!success)
        {
            fprintf(stderr, "Could not set comm mask.\n");
        }
    
        OVERLAPPED osStatus = {0};
        osStatus.hEvent = CreateEvent(NULL, true, false, NULL);
        assert(osStatus.hEvent);
    
        DWORD dwCommEvent;
        BOOL fWaitingOnStat = FALSE;
        while (true)
        {
            // Issue a status event check if one hasn't been issued already.
            if (!fWaitingOnStat)
            {
                //fprintf(stderr, "Calling WaitCommEvent\n");
                if (!WaitCommEvent(port, &dwCommEvent, &osStatus))
                {
                    if (GetLastError() == ERROR_IO_PENDING)
                    {
                        fWaitingOnStat = TRUE;
                        //fprintf(stderr, "WaitCommEvent result is ERROR_IO_PENDING\n");
                    }
                    else
                    {
                        fprintf(stderr, "Error in WaitCommEvent\n");
                        break; // abort
                    }
                }
                else
                {
                    // WaitCommEvent returned immediately.
                    // Deal with status event as appropriate.
                    ReportStatusEvent(dwCommEvent);
                }
            }
    
            // Check on overlapped operation.
            if (fWaitingOnStat)
            {
                DWORD dwOvRes;
    
                // Wait a little while for an event to occur.
                //fprintf(stderr, "Calling WaitForSingleObject\n");
                DWORD dwRes = WaitForSingleObject(osStatus.hEvent, 100);
                switch(dwRes)
                {
                case WAIT_OBJECT_0:
                    // Event occurred.
                    if (!GetOverlappedResult(port, &osStatus, &dwOvRes, FALSE))
                    {
                        // An error occurred in the overlapped operation;
                        // call GetLastError to find out what it was
                        // and abort if it is fatal.
                        fprintf(stderr, "Error from GetOverlappedResult\n");
                    }
                    else
                    {
                        // Status event is stored in the event flag
                        // specified in the original WaitCommEvent call.
                        // Deal with the status event as appropriate.
                        ReportStatusEvent(dwCommEvent);
                    }
    
                    // Set fWaitingOnStat flag to indicate that a new
                    // WaitCommEvent is to be issued.
                    fWaitingOnStat = FALSE;
                    break;
    
                case WAIT_TIMEOUT:
                    // Operation isn't complete yet. fWaitingOnStatusHandle flag
                    // isn't changed since I'll loop back around and I don't want
                    // to issue another WaitCommEvent until the first one finishes.
                    //
                    // This is a good time to do some background work.
                    //fprintf(stderr, "WAIT_TIMEOUT\n");
                    break;
    
                default:
                    // Error in the WaitForSingleObject; abort
                    // This indicates a problem with the OVERLAPPED structure's
                    // event handle.
                    fprintf(stderr, "Error in WaitForSingleObject\n");
                    CloseHandle(osStatus.hEvent);
                    return 70;
                }
            }
        }
    
        return 0;
    }
    
    
    

    public by UdeF modified Mar 8, 2015  125109  0  5  0

    Entfernt das TrayIcon beim Beenden

    entfernt das TrayIcon vor dem beenden aus der Taskleiste.
    OnAutoItExitRegister("__TrayIconHide")
    Func __TrayIconHide()
        TraySetState(2)
    EndFunc
    
    ; MsgBox(0, "hallo", "h")          

    public by lbottaro modified Oct 17, 2013  4017  0  7  0

    How to find and remove directories in windows batch command

    The script will search for a given path and returns the name of folders found. The script may remove the directory found (with or without prompt)
    @echo off
    set m_path="C:\Users"
    if exist %m_path% (
    cd %m_path%
    echo FOUND %m_path%
    REM pippo
    for /F %%i in ('dir obj /s /b') do (
    echo "dir %%i"
    REM Remove dir without prompt
    rmdir %%i /s /q
    REM Remove dir with prompt
    REM rmdir %%i /s
    )
    )
    
    pause

    public by Charles Grunwald modified Aug 22, 2015  639  0  3  1

    Using 7 bytes of preassembled shellcode, determine if the current 32-bit process is running in the WOW64 subsystem (as is the case when running 32-bit Python on 64-bit Windows) or if it's running from a 32-bit Windows OS.

    Using 7 bytes of preassembled shellcode, determine if the current 32-bit process is running in the WOW64 subsystem (as is the case when running 32-bit Python on 64-bit Windows) or if it's running from a 32-bit Windows OS.: iswow64.py
    # encoding: utf-8
    """
    iswow64.py
    Using 7 bytes of preassembled shellcode, determine if the current
    32-bit process is running in the WOW64 subsystem (as is the case
    when running 32-bit Python on 64-bit Windows) or if it's running
    from a 32-bit Windows OS.
    
    This program is free software. It comes without any warranty, to
    the extent permitted by applicable law. You can redistribute it
    and/or modify it under the terms of the Do What The Fuck You Want
    To Public License, Version 2, as published by Sam Hocevar. See
    http://sam.zoy.org/wtfpl/COPYING for more details.
    """
    from _ctypes import _SimpleCData as _SimpleCData
    from ctypes.wintypes import LPVOID, DWORD, INT, BOOLEAN, HANDLE
    from ctypes import WinDLL, POINTER, WinError, c_size_t as SIZE_T, sizeof as SIZEOF, \
                       cast as CAST, byref as BYREF, create_string_buffer as STRALLOC, \
                       WINFUNCTYPE as WINAPI, CFUNCTYPE as CDECL
    
    # Verify we're working on a 32-bit version of Python
    assert(SIZEOF(LPVOID) == SIZEOF(DWORD))
    
    # Kernel32 DLL
    _kernel32 = WinDLL('kernel32.dll')
    
    # Custom Types
    class BOOL(INT):
        """ Just a 32-bit integer interpreted as a boolean. """
    
        def from_param(self, value):
            if value is None:
                return INT(0)
            elif isinstance(value, _SimpleCData):
                return value
            else:
                return INT(value)
    
        def __eq__(self, other):
            value = self.value
            if isinstance(other, bool):
                return value == other
            elif isinstance(other, _SimpleCData):
                return value == bool(other.value)
            else:
                return value == bool(other)
    
        def __hash__(self):
            return hash(self._as_parameter_)
    
    
    # Typedefs
    LPCVOID = LPVOID
    PDWORD = POINTER(DWORD)
    PSIZE_T = POINTER(SIZE_T)
    
    # Constants
    NULL = LPVOID(0)
    NULL_PDWORD = CAST(NULL, PDWORD)
    NULL_PSIZE_T = CAST(NULL, PSIZE_T)
    
    ## Param values for flAllocationType & dwFreeType
    MEM_RESERVE = DWORD(0x00002000)
    MEM_COMMIT = DWORD(0x00001000)
    MEM_RELEASE = DWORD(0x8000)
    
    ## Param values for flProtect & flNewProtect
    PAGE_READWRITE = DWORD(0x04)
    PAGE_EXECUTE_READWRITE = DWORD(0x40)
    
    ## Param flags Constants
    _In = 1
    _Out = 2
    _InOpt = 3
    _InOutOpt = _InOpt | _Out
    
    # Win32 API Function Prototypes
    
    """ HANDLE WINAPI GetCurrentProcess(void); """
    GetCurrentProcess = WINAPI(HANDLE)(('GetCurrentProcess', _kernel32))
    hCurrentProcess = GetCurrentProcess()
    
    """ LPVOID WINAPI VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) """
    VirtualAlloc = WINAPI(LPVOID, LPVOID, SIZE_T, DWORD, DWORD)(
        _kernel32.VirtualAlloc
    )
    
    """ BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) """
    VirtualFree = WINAPI(BOOL, LPVOID, SIZE_T, DWORD)(
        _kernel32.VirtualFree
    )
    
    """ BOOL VirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect) """
    VirtualProtect = WINAPI(BOOL, LPVOID, SIZE_T, DWORD, PDWORD)(
        _kernel32.VirtualProtect
    )
    
    """ BOOL WINAPI WriteProcessMemory(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumofBytesWritten) """
    WriteProcessMemory = WINAPI(BOOL, HANDLE, LPVOID, LPCVOID, SIZE_T, PSIZE_T)(
        _kernel32.WriteProcessMemory
    )
    
    """ BOOL WINAPI FlushInstructionCache(HANDLE hProcess, LPCVOID lpBaseAddress, SIZE_T dwSize) """
    FlushInstructionCache = WINAPI(BOOL, HANDLE, LPCVOID, SIZE_T)(
        _kernel32.FlushInstructionCache
    )
    
    def destroy_cfunc(cfuncproc):
        """
    
        :param cfuncproc:Stuff
        :type cfuncproc:ctypes.CFUNCTYPE
        :return:Success
        :rtype:bool
        """
        if isinstance(cfuncproc, LPVOID):
            cptr = cfuncproc
            csize = cfuncproc._allocsize
        else:
            cptr = cfuncproc._cptr
            csize = cfuncproc._procsize
        return bool(VirtualFree(cptr, csize, MEM_RELEASE))
    
    def create_cfunc(cfunctype, shellcode):
        """
    
        :param cfunctype: The function prototype to use for creation.
        :type cfunctype: ctypes.CFUNCTYPE
        :param shellcode: List of bytes forming the shellcode
        :type shellcode: list
        :return:The callable function in memory.
        :rtype:ctypes.CFUNCTYPE
        """
        # Grab the size of the shellcode
        shellcode_size = len(shellcode)
    
        # Reserve memory for our shellcode bytes
        lpAllocated = LPVOID(VirtualAlloc(NULL, shellcode_size, MEM_RESERVE, PAGE_EXECUTE_READWRITE))
        if not lpAllocated or (hasattr(lpAllocated, 'value') and lpAllocated.value is None):
            raise WinError()
    
        # Commit our allocation to obtain our allocated memory.
        lpRes = VirtualAlloc(lpAllocated.value, shellcode_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
        lpAllocated._allocsize = shellcode_size
    
        # Alter protection flags on the memory region that will contain our code.
        # if not VirtualProtect(lpAllocated.value, shellcode_size, PAGE_EXECUTE_READWRITE, NULL_PDWORD):
        #     destroy_cfunc(lpAllocated)
        #     raise WinError()
    
        # Assemble our shellcode buffer, then copy it over to our allocated memory.
        shellcode_buffer = STRALLOC(''.join(map(chr, shellcode)), shellcode_size)
        WriteProcessMemory(hCurrentProcess, lpAllocated, CAST(shellcode_buffer, LPVOID).value, shellcode_size, NULL_PSIZE_T)
    
        # Flush our instruction cache, and apply our prototype, then return the result.
        FlushInstructionCache(hCurrentProcess, lpAllocated, shellcode_size)
        cfuncproc = cfunctype(lpAllocated.value)
        cfuncproc._cptr = lpAllocated
        cfuncproc._procsize = shellcode_size
        return cfuncproc
    
    IsWow64ShellCode = [  # _IsWow64:
        0x66, 0x8C, 0xC8,    #     mov ax, cs
        0xC1, 0xE8, 0x05,    #     shr eax, 5
        0xC3                 #     ret
    ]
    
    ISWOW64FUNCTYPE = CDECL(BOOLEAN)
    IsWow64 = create_cfunc(ISWOW64FUNCTYPE, IsWow64ShellCode)
    if IsWow64():
        print 'IsWow64 = True'
    else:
        print 'IsWow64 = False'
    destroy_cfunc(IsWow64)
    
    
    

    public by FMXExpress modified Nov 13, 2014  8959  90  7  1

    Non Blocking Message Dialog For Delphi XE7 Firemonkey

    MessageDlg(‘Do you want to press yes or no?’, System.UITypes.TMsgDlgType.mtInformation,
      [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
        procedure(const AResult: TModalResult)
        begin
          case AResult of
            { Detect which button was pushed and show a different message }
            mrYes:
                begin
                // pressed yes
                end;
            mrNo:
                begin
                // pressed no
                end;
          end;
        end
      );
    // code here would get executed right away

    public by lbottaro modified Mar 18, 2013  4912  7  6  1

    smbclient to remotely copy from linux to windows env

    This script allows to keep synchronized a windows based client with a linux machine. Details for smbclient command: -U: set the credentials to login -c: execute a command (between quotes) The command executed includes: -lcd: set the specified directory to local machine -mput: copy one or more local files to the remote computer
    #!/bin/bash
    
    # Linux source directory to copy from: /home/tmp/
    # Windows target directory where to copy: \\1.2.3.4\SharedDirectory\filesDir
    
    user=myUser
    pwd=myPwd
    targetIP=1.2.3.4
    sharedDirRoot=SharedDirectory
    targetDir=filesDir
    linuxSourceDir=/home/tmp/
    
    echo '- Updating Client folder -'
    smbclient -U $user%$pwd //$targetIP/$sharedDirRoot -c "cd $targetDir; lcd $linuxSourceDir; prompt off;recurse; mput *;"
    echo '- Remote Client Updated -'

    public by lbottaro modified Nov 12, 2012  2697  0  6  0

    C# Delegate method for Windows Form application

    This delegate method can be invoked by a thread (e.g. a background worker thread running into the Window form app) to update the Form GUI asynchronously.
    /// <summary>
    /// ...
    /// </summary>
    /// <param name="text"></param>
    /// <param name="oo"></param>
    private void updateLabel(System.Windows.Forms.Label label, object oo)
    {
       Invoke(new MethodInvoker(
         delegate { label.Text = oo.ToString(); }
         ));
    }
    • Public Snippets
    • Channels Snippets