Archive

Posts Tagged ‘microsoft’

Create a shortcut with script

13 August 2018 Leave a comment

I create a shortcut with a script, but why? Some applications do not know the cause, do not create a shortcut during installation or after installation. The following Script allows you to create shortcuts with the variables entered.

VBScript

The shortcut name, shortcut path, file name of the target application, shortcut icon, and system architecture are automatically selected.

Script

‘Script Started

‘Option Explicit

‘Create Shortcut

strComputer = “.”

On Error Resume Next

Dim objShell, objDesktop, objLink, strDesc,objItem ,colItems

Dim strAppPath, strWorkDir , WshShell

Set WshShell     = Wscript.CreateObject(“Wscript.Shell”)

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colItems = objWMIService.ExecQuery(“Select * from Win32_ComputerSystem”,,48)

For Each objItem in colItems

If objItem.SystemType = “x64-based PC” Then

‘Variables

strWorkDir =”C:\”

strAppPath = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

strDesc=”Google Chrome”

‘——

Set objShell = CreateObject(“WScript.Shell”)

objDesktop=objShell.SpecialFolders(“Desktop”)

Set objLink = objShell.CreateShortcut(objDesktop & “\Google Chrome.lnk”)

objLink.Description = strDesc

objLink.TargetPath = strAppPath

objLink.WindowStyle = 3

objLink.WorkingDirectory = strWorkDir

objLink.IconLocation = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

objLink.Save

‘————————————-‘

‘ Add Registry key

else

‘Variables

strWorkDir =”C:\”

strAppPath = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

strDesc=”Google Chrome”

‘——

Set objShell = CreateObject(“WScript.Shell”)

objDesktop=objShell.SpecialFolders(“Desktop”)

Set objLink = objShell.CreateShortcut(objDesktop & “\Google Chrome.lnk”)

objLink.Description = strDesc

objLink.TargetPath = strAppPath

objLink.WindowStyle = 3

objLink.WorkingDirectory = strWorkDir

objLink.IconLocation = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

objLink.Save

end if

next

wscript.quit

‘Script Finished

Enjoy!

 

 

Advertisements

PowerShell: Get information for an update installation when it is started, finished, and how long take

09 August 2018 Leave a comment

Microsoft’s updates never end. According to some system administrators, this is a headache. According to some system administrators, it is necessary for security. Although you are working with too many updates, in some cases you may need detailed information about the update installation. When did the update begin? When was the update installed? How long was the update set up?

PowerShell_ISE
In such situations grab the PowerShell help 🙂
The following codes fetch this information about the update you specified from the machine’s EventView logs.

Update_Installation

$eventt=Get-WinEvent -FilterHashtable @{Logname = ‘setup’; id = 1} |
Select Message, Timecreated | Select-String -Pattern ‘KB4339420\d*’ –AllMatches

$eventt |
foreach{
$zaman=(($_.line).split(“;”)[1].split(” “)[2]).replace(“}”,””)
$KB2=$_.matches
$kb=$kb2 | foreach{$_.value}
Write-host $KB “Installation start time” $zaman
}

$eventt2=Get-WinEvent -FilterHashtable @{Logname = ‘setup’; id = 4} |
Select Message, Timecreated | Select-String -Pattern ‘KB4339420\d*’ –AllMatches

$eventt2 |
foreach{
$zaman2=(($_.line).split(“;”)[1].split(” “)[2]).replace(“}”,””)
$KB4=$_.matches
$kb3=$kb4 | foreach{$_.value}
Write-host $KB3 “Installation finish time” $zaman2
[timespan]$sonuc=[timespan]$zaman2-[timespan]$zaman
write-host $KB3 ” update installed in ” $sonuc.minutes “minute(s) and ” $sonuc.seconds “second(s)”
}

Note: I have set these codes so that they get information for the update that was set up during the day. If you need information for a different day, you may need to make changes.

Problems refreshing icons on desktop and system tray (Solution)

I have come across a problem with a few customers, at least a couple of machines, with the problem of not refreshing the System Tray ( right next to the clock wlEmoticon-winkingsmile.png ) and the desktop icons.

2018-07-16_14-21-29

You can simply solve this problem by following the steps below.
Lets start,

To refresh system tray icons;

HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify

find and delete IconStreams ve PastIconStream variables on the right pane,

2018-07-16_14-28-08

Ctrl-Alt-Delete and open Task Manager, select explorer.exe under Processes and Finish Process.

Click Applications, select New Task, type explorer.exe and press Enter.

To refresh the desktop icons;

C:\Users\<user name>\AppData\Local
go to folder, delete the hidden IconCache.db file, and then restart the computer.

Enjoy.

Useful 10 WQLs Query for SCCM Collections #2

 

Let’s continue with handy WQLs. I continue to share WQLs that many companies have used in their SCCM project and consulting. Do not hesitate to contact me if you have WQLs that you have in mind, or if you need them.

Enjoy!

sccm-logo

Read more…

Useful 10 WQLs Query for SCCM Collections #1

 

Collections are basement of SCCM administration. I want to share some useful WQL for get more detailed environment.

Enjoy!

sccm-logo

Read more…

Get windows registry value from remote computer

If you manage a large domain network. Your manager may ask you for information about the applications that are installed on the systems at certain intervals. This program can be more important for this company if it is an expensive application.

In the following example, we try to determine which machines have visual studio by collecting registry key information

Goal: Read registry value from remote machine

Source: Read remote machine names from .txt file

Result: Get results in .csv format

Read more…

Windows Time Zones

When you need change time zone in Windows operating system,  you need to see how many time zone supported by your current operating system. You can use the following easy CMD command for get full list of time zones.

tzutil /l

Read more…