Loop through directory and call .Net gacutil to register assembly
noob here. i've tried several different examples can't work. use cmd line i'm trying learn little powershell. help. here's have far.
$gacutil = "c:\program files (x86)\microsoft sdks\windows\v7.0a\bin\gacutil.exe" $dllpathcore11 = "\\buildmachine\commonlibraries\main\core\1.1\chi*.dll"
#add gacutil path $oldpath=(get-itemproperty -path 'registry::hkey_local_machine\system\currentcontrolset\control\session manager\environment' -name path).path $newpath=$oldpath+$gacutil #write-output "new path: " + $newpath set-itemproperty -path 'registry::hkey_local_machine\system\currentcontrolset\control\session manager\environment' -name path –value $newpath ls $dllpathcore11 | foreach -process { $extjob = new-object system.diagnostics.process $extjob.startinfo = new-object system.diagnostics.processstartinfo $args = "/if " + $_.name $returnexitcode = $false $extjob.startinfo.filename = $gacutil $extjob.startinfo.arguments = $args $extjob.startinfo.useshellexecute = $shell $extjob.startinfo.windowstyle = 0 $extjob.startinfo.redirectstandardoutput = $true $null = $extjob.start() $extjob.waitforexit() $returnexitcode = $extjob.exitcode $resulttxt = $extjob.standardoutput.readtoend() # write-output "filename: " + $_.name write-output "exit code:" + $returnexitcode }
-will
i see 2 issues:
- you don't need add gacutil path variable. specifically, adding full path exe instead of directory. however, supplying full path process object, adding path environment variable unnecessary.
- your line $args should $args = "/if " + $_.fullname to supply gacutil full path , not file name.
Windows Server > Windows PowerShell
Comments
Post a Comment