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
MPREv

Windows 7
 
 
Portin from Batch to Powershell?

Hallo,

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

1)
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.
Code:
	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
logicearth

Windows 10 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
EricL

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
.

Reply

 Portin from Batch to Powershell?




Thread Tools





Similar help and support threads
Thread Forum
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch rename in DOS or Windows Powershell
Hi - sorry if this is not the right forum - please feel free to move this is need be. So, I have this for batch renaming files in a folder: Dir | rename-item -newname { $_.name -replace "oldname","newname" } And it works like a charm. The thing I can not figure out how to do is add...
General Discussion
PowerShell 3.0 for Win 7 now available
Download: WMF 3.0 - Microsoft Download Center - Download Details You will notice in the requirements that Service Pack 1 must be installed. You will be downloading: Windows Management Framework 3.0 which includes: PowerShell 3.0, WMI & WinRM
News
Powershell get-acl help
Hi, I was thinking of making a script for powershell, but it was harder than i thought. I'am a beginner of the beginners when it comes to powershell, so i was wondering if any of you could help me (or maybe make me one) with making one. This is what i was thinking of(not sure if this is even...
Software
powershell 1 or 2?
i thought windows 7 pro comes with powershell 2 installed.... when i look in sys32 folder it shows powershell 1... also when powershell is activated it is version 1.... is this correct or what is going on... system is fully updated... win 7 pro 64 bit thanks :(
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 02:25.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App