Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 40 Next »

vi

https://www.cs.colostate.edu/helpdocs/vi.html

Macintosh

Killing Things

Quit an App

osascript -e ‘tell application “safari” to quit’

Starting A Shell Script

#!/bin/bash

Split a Text File into pieces based on text

(The text in this case is "1 row"

split -p '^1 row.*' Software\ on\ Refreshing\ Windows\ Computers.txt 

Ditto

Creating a zip file

sudo -s

ditto -ck foldername foldername.zip

DiskUtil

Converting from core storage

diskutil cs list

copy 1st GUID

diskutil cs delete GUID

 

"Change Image Host Name"

after deploying image but NOT restarting, open a terminal window from the utilities menu

defaults read /Volumes/Macintosh\ HD/var/kace/ds/imageinfo.plist

defaults write /Volumes/Macintosh\ HD/var/kace/ds/imageinfo.plist ImageHostname XXXX###-##XX

Remove Quarantine Flag from an app

remove a from a .dmg or .zip before unpacking

from a terminal window

xattr -c nameofthe.dmg

Windows

 

Batch File Reference

http://steve-jansen.github.io/guides/windows-batch-scripting/index.html

If Statement Examples:

IF, no ELSE

if exist %SystemRoot%\system32\Macromed\Flash\flash.ocx %SystemRoot%\system32\Macromed\Flash\UninstFl.exe -q -u %SystemRoot%\system32\Macromed\Flash\flash.ocx
if exist %SystemRoot%\system32\Macromed\Flash\flash6.ocx %SystemRoot%\system32\Macromed\Flash\UninstFl.exe -q -u %SystemRoot%\system32\Macromed\Flash\flash6.ocx

IF, ELSE

If Exist C:\Windows\SysWOW64 (
 do some stuff for 64-bit Windows
 do maybe another line of stuff
 ) ELSE (
do some other stuff for 32-bit Windows
and maybe another line of stuff
 )

IF, ELSE, GOTO

If Exist C:\Windows\SysWOW64 (
 GOTO x64
 ) ELSE (
GOTO x86
 )
 
:x64
do some stuff
GOTO END
 
:x86
do some stuff
GOTO END
 
:END
 
 

 

Converting to gpt

 

CMD:

Diskpart

select disk 0 

clean

convert gpt

Powershell:

Clear-Disk -Number 0

Initialize-Disk -Number 0 -PartitionStyle GPT

 

Getting System Info

Detecting Windows Version

CMD:

 ver | find "6.3" >nul && goto WIN8

This will detect Windows 8 and goto a section in a batch file for Win8

Powershell:

$Bitness = Get-WMIObject win32_operatingsystem

$Bitness.OSarchitecture 

or

(Get-WMIObject win32_operatingsystem).OSarchitecture 

Get-WindowsEdition -Verbose -Online

Detecting Hardware Model

  if /i "%WMICModel:~0,7%"=="20074DU" set TP=y

Detects Model = 20074DU and sets a variable

Killing Things

Kill a task

CMD:

taskkill /F /IM iTunesHelper.exe

PowerShell:

 Stop-Process -Force -Name iTunesHelper

Stop a Service

CMD:

net stop "Apple Mobile Device"
net stop "Intel(R) Management and Security Application Local Management Service"

Powershell:

Stop-Service -Force -DisplayName "Apple Mobile Device"

Stop-Service -Force -DisplayName "Intel(R) Management and Security Application Local Management Service"

Introducing wait time

PING -n 30 127.0.0.1>NUL

Installing Things

Install an MSI based Program

msiexec.exe /i ENX7Inst.msi USERCANAPPLYUPDATES=F /qb 

Apply an MSI patch

msiexec.exe /update ENX7Update.msp /qb

Using 7-Zip to Unzip to a directory

 

"%~dp07za.exe" x -y -o"C:\Program Files (x86)\NotePadPlusPlus" "%~dp0npp.6.6.6.bin.7z"

Testing for 64bit Windows

CMD:

If Exist C:\Windows\SysWOW64 (
 do some stuff for 64-bit Windows
 ) ELSE (
do some other stuff for 32-bit Windows
 )
Powershell:

 

$x = Get-WmiObject win32_operatingsystem
if( $x.OSArchitecture -eq "64-bit") { 
       do stuff in 64-bit Windows
       } else {
       do some stuff in 32-bit Windows
       }

 

 
Getting to the Native cmd prompt
========================================================
@echo off
if not exist c:\windows\sysnative\cmd.exe goto :gonenative
echo Relaunching with x64 cmd.exe...
c:\windows\sysnative\cmd.exe /C "%~dpnx0"
goto :EOF

:gonenative
REM ---paste the rest of your batch code below this line---

========================================================
xcopy flags

/e /c /i /h /r /y /z

Dealing with UnTrusted Drivers

http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/

The solution is quite simple. Using a VM or a system for testing, install the software and check off "Always Trust software from [Publisher]". What this does is place a certificate in the local computers certificate store that will rid future installs from Novell of this dialogue. What we do then, is export the certificate and put it into your install script. Follow the below to conquer this problem:

  1. In your test environment, install the program fully and be sure to click 'Always trust software from [Publisher]
  2. Run certmgr.msc and navigate to Trusted Publishers then Certificates
  3. The certificate from the publisher will show up there. Right click and click All Tasks -> Export. Save the file.

You now have the certificate from the test environment. You need to import this to the computers being deployed to prior to the install. Simply run the following command in your install script before the program install:

certutil -addstore "TrustedPublisher" MyCertificate.cer

Uninstalling Things

Uninstall an MSI based Program

echo Attempting to uninstall Endnote X6
MsiExec.exe /x{86B3F2D6-AC2B-0016-8AE1-F2F77F781B0C} /qn

You can find this code in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

Running an Uninstall.exe from an Unknown folder

FOR /D %%G in ("c:\Program Files\R\*") Do "%%G\unins000.exe" /SILENT
FOR /D %%G in ("c:\Program Files (X86)\R\*") Do "%%G\unins000.exe" /SILENT

Deleting a folder with a wildcard

for /D %%f in ("c:\Program Files\Inkscape"*) do rd "%%f" /s /q

Cleanup
Delete Desktop Shortcuts

FOR /D %%G in ("c:\Users\*") Do del "%%G\Desktop\EditPad Lite 7.lnk"

If you know the location of the shortcut, you can do the following:

del /F /Q "yourpathhere"

i.e. del /F /Q "c:\Users\Public\Desktop\Evernote.lnk"

Copying Start Menu Shortcuts

mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\NotepadPlusPlus"

xcopy "startmenu\notepad++.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\NotepadPlusPlus" /e /c /i /h /r /y /z

Adding Firewall Exceptions
	netsh advfirewall firewall add rule name="Google Earth" dir=in action=allow program="C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"

 

Registry Stuff

Importing into the 64bit Registry

reg.exe import registryfile.reg /reg:64

Verifying stuff in the 64bit Registry in a KBOX Script

Verify that

HKLM64\Software\path to your stuff

Deleting Registry Keys

reg delete HKLM\Software\wOW6432Node\Inkscape /f 


reg delete HKLM\Software\Inkscape /f

K1000

/wiki/spaces/itskb/pages/26116466

Google

Remove Duplicates

https://developers.google.com/apps-script/articles/removing_duplicates

Script Text

function removeDuplicates() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var newData = new Array();
  for(i in data){
    var row = data[i];
    var duplicate = false;
    for(j in newData){
      if(row.join() == newData[j].join()){
        duplicate = true;
      }
    }
    if(!duplicate){
      newData.push(row);
    }
  }
  sheet.clearContents();
  sheet.getRange(1, 1, newData.length, newData[0].length)
      .setValues(newData);
}

Get Usernames from K1000 Inventory Dump (User Logged)

=IF(LEFT(O2,4)="ADS\", RIGHT(O2,LEN(O2)-4), O2)

Append to username

=B2&"@carleton.edu"

Conditional Format if Data in H1 is listed in Column K of PilotUsers Sheet

=match(H1,indirect("PilotUsers!K:K"),0)

Return data in Column 1 that is NOT in Column 2

=ArrayFormula(FILTER('2018.11.09 All'!A:A,ISERROR(match('2018.11.09 All'!A:A,'2018.10.09 All'!A:A,0))))



  • No labels