System Programming

40K

Solutions

18

Articles & Videos

19K

Contributors

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.

Share tech news, updates, or what's on your mind.

Sign up to Post

The script below does a count of the existing folders and if the count is different the next time it runs then it will generate an Event ID. The problem that I have with the existing approach is that when a folder is purged/deleted the count is no longer valid and we will be a false positive.

Instead of the .count we need to find if a new folder has been created. I am not sure if there is a way to do it by date? or some other way so that when folders are deleted we don't get falser positives.

Basically the goal is to have a script which will run from SCOM the target machine (every 30 min) to verify if a new folder has been created in a specific path, if so then will generate an event ID. SCOM will monitor the event-id and generate an alert.

The script below works great, but we need to replace the count with something that will be more date oriented.

Thank you!

---------------

#requires -version 3
New-EventLog -LogName Application -Source "MyScript" -ErrorAction SilentlyContinue
$basecountfile = "$env:HOMEDRIVE\scripts\basecount.txt"
if (test-path -Path $basecountfile){
  # if file not found then this is the first run so there is no baseline
  # otherwise check the path and count the directories and compare against the baseline
        $previouscount = get-content -path $basecountfile
        $basecount = (get-childitem -Path \\server\folder -Recurse -Directory).count
        if ($basecount -ne $prevouscount) {
        # found a difference
         

Open in new window

0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,
Using these codes (in the project),
        private static Cell InsertCellInWorksheet(string columnName, uint rowIndex, WorksheetPart worksheetPart)
        {
            Worksheet worksheet = worksheetPart.Worksheet;
            SheetData sheetData = worksheet.GetFirstChild<SheetData>();
            string cellReference = columnName + rowIndex;
            Row row;
            if (sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).Count() != 0)
            {
                row = sheetData.Elements<Row>().Where(r => r.RowIndex == rowIndex).First();
            }
            else
            {
                row = new Row() { RowIndex = rowIndex };
                sheetData.Append(row);
            }
            if (row.Elements<Cell>().Where(c => c.CellReference.Value == columnName + rowIndex).Count() > 0)
            {
                return row.Elements<Cell>().Where(c => c.CellReference.Value == cellReference).First();
            }
            else
            {
                Cell refCell = null;
                foreach (Cell cell in row.Elements<Cell>())
                {
                    if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
                    {
                        refCell = cell;
                        break;
                    }
                }
                Cell newCell = new Cell() { CellReference = cellReference };
                row.InsertBefore(newCell, refCell);
                

Open in new window

0
Hi,
Is there one example to read each message, one by one, for one specific text string, within Sent folder of Outlook?
0
I installed C++ builder 6.0 on windows 10.
when I reopen a project , my working directory don't change to new project path and my new forms create on the directory that last time I used "FILE->Open Project" method.
if every body knows how can say to it change to the project path after reopen .
-- thanks reza
0
Hi,
Further to this
https://www.experts-exchange.com/questions/29029100/Problem-to-show-list.html?anchor=a42174635¬ificationFollowed=190745230#a42174635

and I have ImageHandler.cs like
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Xml;
using System.Globalization;
using System.Collections.Generic;
using System.Drawing;
using System.Text; // This was needed to make ASCIIEncoding function
using System.Security.Cryptography; // This was needed to make everything related to MD5 function
using System.Web.Services;

namespace Own_rec
{
    public class ImageHandler : IHttpHandler
    {
        /// <summary>
        /// You will need to configure this handler in the Web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            //string userId = string.Empty;
            int userId = 0;
            //-- get the ID from query string you get from <img src tag
            if (null != 

Open in new window

0
Hi,
Using these codes

        public static List<HouseData> GetHouseList()
        {
            List<HouseData> houseList = new List<HouseData>();
            using (SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mssqlconn3"].ConnectionString))
            {
                using (SqlCommand sqlCmd = new SqlCommand("SELECT house_name, address1, address2, price, price_curr, raised_by_user_id FROM house_tab", sqlConn))
                {
                    sqlConn.Open();
                    sqlCmd.CommandType = CommandType.Text;
                    SqlDataAdapter sqlAd = new SqlDataAdapter(sqlCmd);
                    DataTable sqlDt = new DataTable();
                    sqlAd.Fill(sqlDt);
                    sqlConn.Close();
                    if (null != sqlDt)
                    {
                        houseList = sqlDt
                                        .AsEnumerable()
                                        .Select(dataRow => new HouseData
                                        {
                                            house_name = dataRow.Field<string>("house_name"),
                                            address1 = dataRow.Field<string>("address1"),
                                            address2 = dataRow.Field<string>("address2"),
                                            price = dataRow.Field<decimal>("price"),
                                            price_curr = 

Open in new window

0
Hi,
How to adjust to list below, to have also one picture file included, that is retrieved from database?

            using (SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mssqlconn3"].ConnectionString))
            {
                using (SqlCommand sqlCmd = new SqlCommand("SELECT house_name, address1, address2, price, price_curr FROM house_tab", sqlConn))
                {
                    sqlConn.Open();
                    sqlCmd.CommandType = CommandType.Text;
                    SqlDataAdapter sqlAd = new SqlDataAdapter(sqlCmd);
                    DataTable sqlDt = new DataTable();
                    sqlAd.Fill(sqlDt);
                    sqlConn.Close();
                    if (null != sqlDt)
                    {
                        houseList = sqlDt
                                        .AsEnumerable()
                                        .Select(dataRow => new HouseData
                                        {
                                            house_name = dataRow.Field<string>("house_name"),
                                            address1 = dataRow.Field<string>("address1"),
                                            address2 = dataRow.Field<string>("address2"),
                                            price = dataRow.Field<decimal>("price"),
                                            price_curr = dataRow.Field<string>("price_curr"),
                                        })
         

Open in new window

0
I use Ola Hallengren's maintenance for all of my customer's, https://ola.hallengren.com/sql-server-backup.html.
Have used it for years, never any real problems -- until now.  For some reason the @CleanupMode and @CleanupTime are not working. The backup step is configured to retain bak files for only 24hrs, and to cleanup the old bak before generating the new.  For some reason, it is not working, and the job keeps failing due to insufficient disk space.

My temporary workaround is below.  I am deleting the largest bak file from disk as a first step in the job, until I get Ola's logic corrected.  Well, it works great as-is, but I've found I need to run it for all subdirectories.

The way it works now is to del the bak file in this path explicitly:
SET @path = 'dir \\backups\servername\dbname\FULL\'

I need it to delete the bak files from all subdirectories within \\backups\servername\

Any help?



SET NOCOUNT ON;

IF OBJECT_ID('tempdb..#files') IS NOT NULL
DROP TABLE #files;
CREATE TABLE #files (Line VARCHAR(512)) 
DECLARE @path VARCHAR(49) 
DECLARE @cmd1 VARCHAR(155)
DECLARE @cmd2 VARCHAR(155)
DECLARE @filename VARCHAR(255)
SET @path = 'dir \\backups\servername\dbname\FULL\'
SET @cmd1 =  @Path+' /A-D  /B' 
--PRINT @cmd1

INSERT #files
EXEC master..xp_cmdshell @cmd1
DELETE #files WHERE Line IS NULL
--SELECT * FROM #files

SET @filename = (SELECT Line FROM #files)
SET @cmd2 = 'del \\backups\servername\dbname\FULL\' + @FileName
--PRINT @cmd2

IF EXISTS(SELECT

Open in new window

0
I am attempting to register a remote machine on team services with Powershell. When I enter the script on the remote machine and attempt to run it, I get the error below: Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found. I have copied the registration script from the Deployment Groups section on team services online.

The server that I am using is windows server 2008 R2. The script is below:

$ErrorActionPreference="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”)){ throw "Run command in Administrator PowerShell Prompt"};If(-NOT (Test-Path $env:SystemDrive\'vstsagent')){mkdir $env:SystemDrive\'vstsagent'}; cd $env:SystemDrive\'vstsagent'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip";(New-Object Net.WebClient).DownloadFile('https://github.com/Microsoft/vsts-agent/releases/download/v2.116.1/vsts-agent-win7-x64-2.116.1.zip', $agentZip);Add-Type -AssemblyName System.IO.Compression.FileSystem;[System.IO.Compression.ZipFile]::ExtractToDirectory($agentZip, "$PWD");.\config.cmd --deploymentgroup --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'https://aaosprojects.visualstudio.com/' --projectname 'xxxxxxxProjects' --deploymentgroupname "xxxxxxxxxDeploymentGroup" ; Remove-Item $agentZip;
0
I have a problem with my mouse. When i move it to the right it goes down, when i move it to the left it goes up, when i move it up it goes to the right, when i move it down it goes to the left.

i really want to use my mouse can somebody help me.

Im using Armageddon Aquila-X5
0
[Webinar] How Hackers Steal Your Credentials
LVL 9
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Hello, Experts,

I have an issue with a script where I want the end-user once the app is hit to see the main menu. I have four definitions doing separate tasks (updating, querying or adding in records in a database).

I want my main screen to pop up a list of items for the end users to select. I read that a def main() function is the route to go. Tested it out and I have no luck running it.

def main():
    user_exit =  5
    while True:
            #prints statements that lead the end-user to decide what they would like to do
        print('Welcome to the ROWriter Database applet! What would you like to do?')
        print('')
        print('1) Insert a new store CIM info...')
        print('2) Update an existing store CIM info...')
        print('3) Delete an exisiting store CIM info...')
        print('4) Search for CIM')
        print('5) Exit the application...')
    
            #accepts user input and converts it to a string and stores into a variable
        user_input = int(input('Enter option:'))
        #if user input is equal to the exit variable then the application exits
        if user_input == user_exit:
            break
        elif user_input == 1:
                option_one()
        elif user_input == 2:
                option_two()
        elif user_input == 4:
                option_four()
  
if__name__ == "__main__":
    
    main()  

Open in new window

0
Is there any way to search for all instances of a string in notepad++ and delete the whole line
on which the string is found?
0
Hi,
I am looking for String Format Method example using various date formats
https://www.javatpoint.com/java-string-format.

I found above link but no example there using the date format though like MMDDYYYY or YYYYMMDD etc to represent date?
please advise
0
Hi,
Is there an example to create list (like what we can get by Gridview) like the following, having Picture file loaded from database?
                <dl id="list_D03_03" onmouseout="mouseOutStyle(this)" onmouseover="mouseOverStyle(this)" class="list rel">
                    <dt class="img rel floatl">
                        <a href="/chushou/3_260353623.htm"  target="_blank">
                            <img width="180" height="135" src="http://img.soufun.com/secondhouse/image/esfnew/search2014/images/loading160_120.gif" src2="http://img11.soufunimg.com/viewimage/agents/2017_05/13/M06/04/17/ChCE4FkWpWiIPlJFAACL93NuA_0AAcAegG1kQ8AAIwP526/220x165c.jpg" onerror="imgiserror(this,'http://img11.soufunimg.com/agents/2017_05/13/M06/04/17/ChCE4FkWpWiIPlJFAACL93NuA_0AAcAegG1kQ8AAIwP526.jpg')" /></a>
                        <p class="txtBg"></p>
                        <p class="txt"><span class="iconImg">10</span></p>
                    </dt>
                    <dd class="info rel floatr">
                        <p class="title"><a href="/chushou/3_260353623.htm"  target="_blank" title="下角</a> 
                            
                        </p>
                        <p class="mt12">
                            2
                            
                            <span class="line">|</span>中
                            <span class='line'>|</span>西
                            <span class='line'>|</span>建
                        </p>
                        

Open in new window

0
Hi,
Is there any C# example code (or other kind of codes) to be able to show a relevant map part from Baidu, per one given city/place location?
0
Hi

In Java, as per a hashtag or a twitter opportunity,

how can I get a list of users that incorporated / responded to that hashtag / question?

Thanks
0
I referred to your post :
https://www.experts-exchange.com/questions/20930458/CreateProcess-for-Currently-Logged-On-User-from-Service-running-System-Account.html
and started building i got error in calling of
HANDLE GetCurrentUserToken()
{
      PHANDLE currentToken = 0;
      HANDLE primaryToken = 0;
      DWORD processID = GetExplorerProcessId();
      HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, processID);
      if (!hProcess)
      {
            LogMessage(ErrorExit(TEXT("OpenProcess Error")));
      }
      if (!OpenProcess(PROCESS_ALL_ACCESS, TRUE, processID))
      {
            LogMessage(ErrorExit(TEXT("OpenProcess Error")));
      }
      if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, currentToken))
      {
            LogMessage(ErrorExit(TEXT("OpenProcessToken Error")));
      }

      if(!DuplicateTokenEx(currentToken,TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS,0, SecurityImpersonation, TokenPrimary, &primaryToken))
      {
            LogMessage(ErrorExit(TEXT("DuplicateTokenEx Error")));
      }

      return primaryToken;
}


Kindly Help me out
0
Hi all,
We are currently in the process of implementing a new financial system which needs to interfaces with several other business systems to process payments. i.e. the source system interfaces with new target financial system to send instruction on people/businesses that need to be paid.  I want to make sure that the details regarding these interfaces are suitably documented.
What I am struggling with in this regard is what we should be documenting.  Some research highlights different expectations and requirements e.g. interface strategies, interface designs, interface control documents, interface specification etc.

My question is what documents should we be creating for the new system as a whole, what documents we should be creating for each specific interface and what kind of information should be included in each?

Some thoughts I have had that we should be recording are:
•      Mapping tables
•      Validations
•      Ownership & Responsibilities
•      Security requirements
•      Data fields being interfaced
•      Interface method
•      Timings
•      How the interface will be processed
•      Reconciliations

TIA
0
Hello guys im learning visual basic 6.0 and as an assignment i was told to come up with a code that backs up and restores my database. So im asking for your assistance, not with the actual code but the steps that i should take so as come up with it myself. Thanks in advance.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

have a basic mfc c++ project built in vs2005 and am just trying to place some text into an edit box on a form
the forms name is and code that access the for is

csdiialog dlg;
dlg.DoModal();
// on the form i have an edit box called IDC_EDIT1 (Edit Control)
// have defined it as dlg then have tried to set the text using
dlg.SetDlgItemText(dlg.m_edit2,"Welcome");
// but throws up the error   c:\c++ projects\usingvccplus\firstsdi\sdi2\sdi2.cpp(98): error C2664: 'CWnd::SetDlgItemTextA' : cannot // convert parameter 1 from 'CString' to 'int'
any help would be appreciated
0
Anyone know a program or Dialing system for making interviews over phone.
Like a system or program that you can make interview questions flows easy. Then save the statistics for later review or send them to a partner.  
Either you have a interview system than a Dialer separated they don't need to be combine into one.
0
Hi,
How to correct
Error      3      The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

while I have Excel 2007 on my Desktop?
0
This development represents an important step forward in AI research, away from mastering tasks like voice,image recognition, and translation, and towards a more nuanced and collaborative AI that adopts a human-like method for decision-making.

Cool competition.  However, if I was capable at creating such AI, I wouldn't do it for $20,000.  I'd sell this AI to the highest bidder!

http://www.techrepublic.com/article/microsoft-competition-asks-phd-students-to-create-advanced-ai-to-play-minecraft/?ftag=TRE684d531&bhid=27457961240876229835964102892079
7
 

Expert Comment

by:ModeIT
for the original? I find that almost hard to believe now.. I used to have a crap load of the maps. I wonder if I saved them along with the game CD. I should rip the CD on for a virtual drive so I can play without it and try to boot an old PC for the game maps..


never did play SC2 :/ it was laggy on my laptop of the time, though my current one should be fine, I wonder what I'd have to pay for a copy now a days
0
 
LVL 16

Author Comment

by:Kyle Santos
Nice.  Yeah, BN is still very much alive.  http://us.battle.net/sc2/en/
I played the full campaigns of SC2.  It was satisfying to finally get the ending of the story.  I thought it was worth it.

You should still have the maps if you haven't wiped your OS or saved the map files on a USB thumb drive haha

CD on for a virtual drive
This.  SO MUCH.
0
I need to detect particular opened apps in my desktop to decide further process in my program by getting its window title. For instance, I will search "Untitled - Notepad" to ensure Notepad is opened and will search "Calculator" to ensure Calculator is opened. Please see the following image for what window title is:
snapshot1.png
The following is the code I have built.

#include "stdafx.h"
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>

//  Forward declarations:
BOOL GetProcessList();
void printError(TCHAR* msg);

int main(void)
{
	GetProcessList();
	return 0;
}

BOOL ListProcessThreads(DWORD dwOwnerPID)
{
	HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
	THREADENTRY32 te32;

	GUITHREADINFO guiInfo = { sizeof(guiInfo) };
	DWORD dwErr = 0;

	LPTSTR app1 = _T("Untitled - Notepad");
	LPTSTR app2 = _T("Calculator");

	// Take a snapshot of all running threads  
	hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
	if (hThreadSnap == INVALID_HANDLE_VALUE)
		return(FALSE);

	// Fill in the size of the structure before using it. 
	te32.dwSize = sizeof(THREADENTRY32);

	// Retrieve information about the first thread,
	// and exit if unsuccessful
	if (!Thread32First(hThreadSnap, &te32))
	{
		printError(TEXT("Thread32First"));  // Show cause of failure
		CloseHandle(hThreadSnap);     // Must clean up the snapshot object!
		return(FALSE);
	}

	// Now walk the thread list of the system,
	// and display information about each thread
	// associated 

Open in new window

0
Mohon bantuan nya
0

System Programming

40K

Solutions

18

Articles & Videos

19K

Contributors

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.