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 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

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
Thread Forum
I was running a script on my 32bit OS that opened up IE and logged me onto my company's vpn. I am now using 64bit OS and My company's vpn does not like 64bit IE. (firefox and chrome are also iffy with our vpn, IE is the only 'official one they support'). When the script runs now on my 64bit os....
General Discussion
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 { $ -replace "oldname","newname" } And it works like a charm. The thing I can not figure out how to do is add...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
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 06:58.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App