Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Portin from Batch to Powershell?

16 Sep 2011   #1

Windows 7
Portin from Batch to Powershell?


Im starting to work with powershell and try to port my old batch files.
Im encounter some problem you may help me with.

I got this lines of Code, and I dont know who to convert them to power shell.
The goal is to uninstall a software using the string found in the registry.
	echo Uninstall old Software now 
	for /F "tokens=1,*" %%i in ('reg query HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\ /s /f APPLICATIONNAME ^|find "Uninstall"') do set StringSearch=%%i
	for /f "tokens=1,2,3,4,5,6,7 delims=\" %%a in ("%StringSearch%") do set ProdID=%%g
	echo ...
	MsiExec.exe /x%ProdID% /quiet
2) In former times I used PsExe to remotly execute scripts on remote positions.
What would be the best practice for power shell.

3) Another question is if it is posible with power shell to tell the system (Win7 and/or Xp)
to do a Windows System Update and install all critical updates?

My System SpecsSystem Spec
16 Sep 2011   #2

Windows 8.1 Pro (x64)

Using the Registry in PowerShell is as easy as working with the file system, both of them use the same interface.
Under The Stairs: Using The Registry with PowerShell
My System SpecsSystem Spec
21 Sep 2011   #3

Windows 7

Hey got some similar problems.
Remote execution could look like:

(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $ip -Credential $cred).InvokeMethod("Win32Shutdown",3)

I'm not sure if this method works for all needs.

I'm also interested in invoking system update via powershell.
My System SpecsSystem Spec

 Portin from Batch to Powershell?

Thread Tools

Similar help and support threads for2: Portin from Batch to Powershell?
Thread Forum
Solved How to run a batch file at logoff & some batch scripting help please Backup and Restore
Batch rename in DOS or Windows Powershell General Discussion
PowerShell 3.0 for Win 7 now available News
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
Solved powershell 1 or 2? General Discussion
do you use powershell? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:36 AM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App