Archive

Posts Tagged ‘vbs’

If the folder exist, appy the .reg file

27 August 2018 Leave a comment

Klasör varsa, .reg dosyasını uygulayın.

regedit

Bazı uygulamaları makine kurduktan sonra ayarlarını her makinede tek tek yapmak gerekebilir. Yada aşağıdaki gibi bir script ile, eğer yüklediğimiz uygulamanın klasörü makinede var ise ayarları Regedit’e yükleyen daha hızlı bir yöntem seçebiliriz.

After installing some applications on the computers, you may need to adjust the settings of the applications one by one. Or, with a script such as the following, we can choose a faster method that installs the settings into Regedit if the machine has the application folder.

Senaryomuz, eğer makinede 32bit Program Files klasörü var ise 32bit ayarların olduğu .reg dosyası uygulansın. Yoksa, 64bit .reg dosyası uygulansın.

Scenario, if you have 32bit Program Files folder on your machine, apply .reg file with 32bit settings. If not, apply 64bit .reg file.

VBScript

‘Script Start here

Dim objFSO

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Set oShell = CreateObject(“Wscript.Shell”)

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

‘reg dosyalari belirlendi

‘reg files determined

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

sRegFilepfx86 = “settingsrunx64.Reg”

sRegFile = “settingsrunx86.Reg”

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

‘klasorler varmi kontrol ediliyor

‘Folders checking if exist

If objFSO.FolderExists(“C:\program files (x86)”) Then

MsgBox “C:\program files (x86) folder exists!”

oShell.Run “regedit.exe /s ” & Chr(34) & sRegFilepfx86 & Chr(34), 0, True

Else

MsgBox “C:\program files (x86) doesn’t exists!”

oShell.Run “regedit.exe /s ” & Chr(34) & sRegFile & Chr(34), 0, True

End If

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

‘Script Finish here

İyi Eğlenceler!

Enjoy!

 

Advertisements

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!