D
D
Dima Kim2016-07-21 14:51:08
PowerShell
Dima Kim, 2016-07-21 14:51:08

Launching cmd after receiving a list with txt, how?

Good afternoon, I need to get a list of installed programs,

@echo off
call :get_soft_list hklm\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
call :get_soft_list hklm\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
call :get_soft_list hkcu\Software\Microsoft\Windows\CurrentVersion\Uninstall
goto the_end

:get_soft_list %1
for /F "tokens=1,2,*" %%a in ('reg query "%1" /s') do ^
if "%%a" == "DisplayName" echo %%c
exit /b

:the_end

you need to run "script.cmd >> result.txt" on computers that are in the pc.txt file, please
help me figure it out

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hdhog, 2016-07-21
@jalpy

here is an option. perhaps not very beautiful, but it should work)
the PsExec utility will be needed. powershell example

Import-CSV ".\computers.csv" -header("ComputerName") | ForEach {
    $ComputerName = $_.ComputerName #чуть-чуть упростим, мне так удобнее :)
    New-Item  $ComputerName\c$\temp -Type Directory 
    Copy-Item "script.cmd" $ComputerName\c$\temp\

    .\psexec.exe \\$ComputerName "C:\\temp\\script.cmd" 
}

will work if the computers are in the domain and have admin rights.
I think it's not difficult to modify)
if winrm works on computers, you can do it without psexec.
also in the case of a domain, you can specify LogoScript that will do everything you need and write the file to the network share

K
Konstantin Tsvetkov, 2016-07-21
@tsklab

I need to get a list of installed programs
Use the free Spiceworks Inventory .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question