Tips: Arch Linux: How to resolve “error: duplicated database entry ” ” error message


Follow the below steps to resolve the issue,

check for versions in local folder

ls /var/lib/pacman/local/ | grep <pkgname>

You should see more then one version mentioned as below

bashank@mayapc1 pkg]$ ls /var/lib/pacman/local/ | grep
bash-4.3.024-1
bash-4.3.027-0.1

now delete (or move them out of local folder) all the older versions from local folder

rm -rf /var/lib/pacman/local/<old_package>

example:

rm -rf /var/lib/pacman/local/bash-4.3.024-1

TIPS: WMI: VBScript: Start a process with different priority


dim intProcessID
Const HIGH = 128
strComputer = “.”

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2:Win32_Process”)
Set objStartup = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2:Win32_ProcessStartup”)
objStartup.PriorityClass = HIGH          !!!!! ‘ Here you can define the priority of the process. !!!!!!
Set objConfig = objStartup.SpawnInstance_
objWMIService.Create( sCommand, sWorkingDir, objConfig, intProcessID)

FAQ: TIPS: WINDOWS: How to find all the process details for a particular executable using command line


wmic process where name=”cmd.exe” get executablepath,Com
mandline,Caption

output:

 Caption CommandLine                   ExecutablePath
 cmd.exe "C:\Windows\system32\cmd.exe" C:\Windows\system32\cmd.exe
 cmd.exe "C:\Windows\system32\cmd.exe" C:\Windows\system32\cmd.exe
 cmd.exe "C:\Windows\system32\cmd.exe" C:\Windows\system32\cmd.exe

TIPS: VBScript : Get Logged in username using VBScript.


  • Using Environment Variable

Set wshShell = WScript.CreateObject( “WScript.Shell” )
strUserName = wshShell.ExpandEnvironmentStrings( “%USERNAME%” )
WScript.Echo “User Name: ” & strUserName

  • Using WshNetwork

Set wshNetwork = WScript.CreateObject( “WScript.Network” )
strUserName = wshNetwork.UserName
WScript.Echo “User Name: ” & strUserName

  • Using ADSI (ADSystemInfo)

Set objSysInfo = CreateObject( “ADSystemInfo” )
strUserName = objSysInfo.UserName
WScript.Echo “User Name: ” & strUserName

  • ADSI (WinNTSystemInfo)

Set objSysInfo = CreateObject( “WinNTSystemInfo” )
strUserName = objSysInfo.UserName
WScript.Echo “User Name: ” & strUserName

  • WMI (Win32_ComputerSystem)

Set objWMI = GetObject( “winmgmts:\\.\root\cimv2” )
Set colItems = objWMI.ExecQuery( “Select * from Win32_ComputerSystem” )
For Each objItem in colItems
strUserName = objItem.UserName
Next

 

Tips: FreeBasic: CopyFolder


#Include once "dir.bi"
#Include once "file.bi"
#Include Once "string.bi"
#include once "ext/strings/strsplit.bi"
#Include Once "win/shlobj.bi"

sub copyfolder(dirName as string, dstdir as string)
    const attrib_mask = fbDirectory  or fbNormal Or fbHidden Or fbSystem or fbReadOnly or fbArchive
    dim as uinteger out_attr
    dim fileName as string
    dim absname as String
    
    fileName = Dir(dirName + "\*", attrib_mask, out_attr)
    print "fileName >>>> " + fileName
    Do Until Len(fileName) = 0 '' loop until Dir returns empty string
        If (fileName <> ".") And (fileName <> "..") Then '' ignore current and parent directory entries
     
            absName = dirName & "\" & fileName
            '
            If out_attr And fbDirectory Then
                dim d as string
                d = right(absName,Len(absName) - InStrRev(absName, "\"))
                Print "d = " + d        
                Print "absName =" + absName                
                dstDir = dstDir + "\" + d 
                Print "DST = " + dstdir
                
                SHCreateDirectoryEx(0,StrPtr(dstDir),0)
                copyfolder(absName, dstDir )
            Else
                dim d as String
                d = right(absName,Len(absName) - InStrRev(absName, "\"))
                SHCreateDirectoryEx(0,StrPtr(dstDir),0)
                FileCopy(absName, dstdir + "\" + d)
                Print "file: " + absName + " DST: " + dstDir
            End If
        End If
      fileName = Dir(out_attr)
    Loop
end sub

Code: Freebasic: runas


#Include "windows.bi"
#inclib "advapi32"

Declare FUNCTION CreateProcessWithLogonW LIB "ADVAPI32" ALIAS "CreateProcessWithLogonW" ( _
        byval lpUsername As LPCWSTR  , _
        BYVAL lpDomain AS LPCWSTR , _
        BYVAL lpPassword AS LPCWSTR, _
        BYVAL dwLogonFlags AS DWORD, _
        BYVAL lpApplicationName AS LPCWSTR , _
        BYVAL lpCommandLine AS LPCWSTR , _
        BYVAL dwCreationFlags AS DWORD, _
        BYVAL lpEnvironment AS DWORD, _
        BYVAL lpCurrentDirectory AS LPCWSTR , _
        lpStartupInfo AS STARTUPINFO, _
        lpProcessInfo AS PROCESS_INFORMATION) AS LONG

Const X_CJ_LOGON_WITH_PROFILE=1
Const X_CJ_CREATE_DEFAULT_ERROR_MODE = &H04000000

FUNCTION RunAsUser(BYVAL UserName AS STRING, _                   
        BYVAL Password AS STRING, _
        BYVAL DomainName AS STRING, _
        BYVAL CommandLine AS STRING, _
        BYVAL CurrentDirectory AS STRING) AS boolean

        Dim si AS STARTUPINFO
        Dim pi AS PROCESS_INFORMATION
        Dim AS String wCurrentDir,wCommandLine,wPassword,wUser,wDomain
        Dim R01 AS LONG

        si.cb = LEN(si)
        wUser = UserName
        wDomain = DomainName
        wPassword = Password
        wCommandLine = CommandLine
        wCurrentDir = CurrentDirectory
        Print wCommandLine & "TEST"
        R01 = CreateProcessWithLogonW(wUser,wDomain,wPassword, _
                        X_CJ_LOGON_WITH_PROFILE, 0&, wCommandLine, _
                        X_CJ_CREATE_DEFAULT_ERROR_MODE, 0&, wCurrentDir, si, pi)
        IF R01  0 THEN
                CloseHandle pi.hThread
                CloseHandle pi.hProcess
                Return TRUE
        ELSE
                Return FALSE
        END If
End FUNCTION

Dim As Long R01
Dim As String  user_name,password,domain,program,workingDir

user_name="username"
password="pa$$word"
domain="domain"
program="C:\\windows\\notepad.exe"
workingDir="C:\\windows"

R01=RunAsUser(user_name,password,domain,program,workingDir)

Tips: wx.Python: Animated Gif in


import wx

import wx.animate # ..\wx\animate.py

class MyPanel(wx.Panel):

“”” class MyPanel creates a panel, inherits wx.Panel “””

def __init__(self, parent=None):

wx.Panel.__init__(self, parent)

self.SetBackgroundColour(“white”)

ag_fname = r”progress.gif”

self.ag = wx.animate.GIFAnimationCtrl(self, -1, ag_fname, pos=(0, 0), size=(64,64))

self.ag.GetPlayer().UseBackgroundColour(True)

self.ag.Play()

#self.ag.Stop()

if __name__ == ‘__main__’:

app = wx.App(redirect = 0)

frame = MyPanel(None)

frame.Show(True)

app.SetTopWindow(frame)

app.MainLoop()

Tips: MSI: Save differences between two msi as MST file using ruby & python


Ruby

require ‘win32ole’
msiClass = WIN32OLE.new(“WindowsInstaller.Installer”)
msidb = msiClass.OpenDatabase(“C:\\temp\\MountPointGenerator.msi”,0)
newmsidb = msiClass.OpenDatabase(“C:\\temp\\updatedMountPointGenerator.msi”,0)
transform = newmsidb.GenerateTransform(msidb,”c:\\temp\\newtest.mst”)

Python

import win32com.client
import os
import sys

msiOpenDatabaseModeReadOnly=0
msidb=r”c:\temp\MountPointGenerator.msi”
msiupdb=r”c:\temp\updatedMountPointGenerator.msi”
mstdb=r”C:\temp\MNPtrans.mst”

installer = win32com.client.Dispatch(“WindowsInstaller.Installer”)
database = installer.OpenDatabase(msidb, msiOpenDatabaseModeReadOnly)
updatedDB= installer.OpenDatabase(msiupdb , msiOpenDatabaseModeReadOnly)
updatedDB.GenerateTransform(database, mstdb)