Help with characters replacement in a INI file and psexec command
Posted: 10 Nov 2022 14:28
I'm currently using the following command to replace some numbers inside an INI file:
powershell -Command "(Get-Content -Path '\\%pc%\c$\patch\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\% pc%\c$\patch\NewSrc\SRC.ini'
This command works fine if the numbers inside the file are 12335, but if anything else, camndo will not work. The question is, is there a way to replace a sequence of unknown characters knowing only what has before it?
Here's how the line with the replaced characters is found inside the .INI file:
EXTENSION=12335
I would like to replace any character set after the "=" with whatever I want without having to know in advance what they are.
Has as?
Another problem I'm having is with p psexec, I wanted to run setup a .reg registry file on a computer remotely. However when I enter the command line, it returns that the specified file could not be found.
Here's what the command line looks like
Copy "c:\troca.reg" "\\%host%\c$\"
psexec \\%host" cmd /c "c:\exchange.reg" /y
or
psexec \\%host" "c:\exchange.reg" /y
or
psexec \\%host" cmd /c "regedit /s c:\exchange.reg"
or
psexec \\%host" regedit /s "c:\exchange.reg"
Even if I specify a user with administrative rights, it returns saying that the specified file could not be found, so I tried this:
PsExec \\%pc% -u "%domain%\%user%" -p "%pass%" -s regedit /s "c:\exchange.reg"
But it returns saying that regedit exited with error 0
Can you guys enlight me?
powershell -Command "(Get-Content -Path '\\%pc%\c$\patch\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\% pc%\c$\patch\NewSrc\SRC.ini'
This command works fine if the numbers inside the file are 12335, but if anything else, camndo will not work. The question is, is there a way to replace a sequence of unknown characters knowing only what has before it?
Here's how the line with the replaced characters is found inside the .INI file:
EXTENSION=12335
I would like to replace any character set after the "=" with whatever I want without having to know in advance what they are.
Has as?
Another problem I'm having is with p psexec, I wanted to run setup a .reg registry file on a computer remotely. However when I enter the command line, it returns that the specified file could not be found.
Here's what the command line looks like
Copy "c:\troca.reg" "\\%host%\c$\"
psexec \\%host" cmd /c "c:\exchange.reg" /y
or
psexec \\%host" "c:\exchange.reg" /y
or
psexec \\%host" cmd /c "regedit /s c:\exchange.reg"
or
psexec \\%host" regedit /s "c:\exchange.reg"
Even if I specify a user with administrative rights, it returns saying that the specified file could not be found, so I tried this:
PsExec \\%pc% -u "%domain%\%user%" -p "%pass%" -s regedit /s "c:\exchange.reg"
But it returns saying that regedit exited with error 0
Can you guys enlight me?