Help with characters replacement in a INI file and psexec command
Moderator: DosItHelp
Help with characters replacement in a INI file and psexec command
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?
Re: Help with characters replacement in a INI file and psexec command
Up,
Any idea abou at least the characters replacements at the .INI files
Any idea abou at least the characters replacements at the .INI files
Re: Help with characters replacement in a INI file and psexec command
For string substitution you should see: help set
You don't provide an .ini file so we don't know how to proceed. Maybe you could make your .ini file from scratch (so you have no need for substitution).
Saso
Code: Select all
%PATH:str1=str2%
would expand the PATH environment variable, substituting each occurrence
of "str1" in the expanded result with "str2". "str2" can be the empty
string to effectively delete all occurrences of "str1" from the expanded
output. "str1" can begin with an asterisk, in which case it will match
everything from the beginning of the expanded output to the first
occurrence of the remaining portion of str1.
Saso
powershell -Command "(Get-Content -Path '\\%pc%\c$\patch\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\% pc%\c$\patch\NewSrc\SRC.ini'
But I need to do this in case there is any other number or nothing after the "=" sign.
So, if you guys can help me
Re: Help with characters replacement in a INI file and psexec command
This works. I tried to use delayedexpansion with no luck. I see you have some spaces at the end of the lines - they are preserved.
Saso
Code: Select all
@echo off
(echo [SRC] )>new_ini.ini
for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call :DOSOME "%%f" "%%g"
goto :EOF
:DOSOME
set new_var=%~1=%~2
REM IF below is CASE SENSITIVE
if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%%ramal%%
(echo %new_var%)>>new_ini.ini
goto :EOF
Re: Help with characters replacement in a INI file and psexec command
Oh I see, I'll try it so.
tks a lot!
tks a lot!
Re: Help with characters replacement in a INI file and psexec command
Worked like a charm.
I still have some code lines before it to run in my batch and need to rename file back to SRC.ini and replace de old one. So can I do it with ren command or need for /f ?
I still have some code lines before it to run in my batch and need to rename file back to SRC.ini and replace de old one. So can I do it with ren command or need for /f ?
Re: Help with characters replacement in a INI file and psexec command
I've tried to change it to get back to my menu config removing goto :EOF and changing it to goto :MENU, but when I do it, the new_ini.ini file turn into a mess, with no data...
Re: Help with characters replacement in a INI file and psexec command
That is more like I need
@echo off
CHCP 65001
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:menu
CLS
ECHO.
ECHO.
ECHO [104;93m ____________________________________ [0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ SUBMENU - Configuração SRC │[0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 1 - Set SRC │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 6 - Exit │[0m
ECHO [104;93m│ RØÐRIGØ │[0m
ECHO [104;93m│────────────────────────────────────│[0m
ECHO.
ECHO [101;1m
CHOICE /N /C:12 /M "Escolha uma opção: "
ECHO [0m
if errorlevel ==2 goto EXIT
if errorlevel ==1 goto SRC
GOTO MENU
:SRC
set /p ramal="Digite o Ramal"
(echo [SRC] )>new_ini.ini
for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call OSOME "%%f" "%%g"
goto :EOF
OSOME
set new_var=%~1=%~2
REM IF below is CASE SENSITIVE
if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal%
(echo %new_var%)>>new_ini.ini
REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE
REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES
PAUSE
goto menu
:EXIT
EXIT
BUT, when I do it, the new_ini.ini file returns almos empyt inside of it, just with this lines inside of
[SRC]
DDD=11
What I'm doing wrong?
@echo off
CHCP 65001
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:menu
CLS
ECHO.
ECHO.
ECHO [104;93m ____________________________________ [0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ SUBMENU - Configuração SRC │[0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 1 - Set SRC │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 6 - Exit │[0m
ECHO [104;93m│ RØÐRIGØ │[0m
ECHO [104;93m│────────────────────────────────────│[0m
ECHO.
ECHO [101;1m
CHOICE /N /C:12 /M "Escolha uma opção: "
ECHO [0m
if errorlevel ==2 goto EXIT
if errorlevel ==1 goto SRC
GOTO MENU
:SRC
set /p ramal="Digite o Ramal"
(echo [SRC] )>new_ini.ini
for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call OSOME "%%f" "%%g"
goto :EOF
OSOME
set new_var=%~1=%~2
REM IF below is CASE SENSITIVE
if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal%
(echo %new_var%)>>new_ini.ini
REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE
REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES
PAUSE
goto menu
:EXIT
EXIT
BUT, when I do it, the new_ini.ini file returns almos empyt inside of it, just with this lines inside of
[SRC]
DDD=11
What I'm doing wrong?
Re: Help with characters replacement in a INI file and psexec command
That's what I'm doing actually
:SRC
CLS
ECHO.
ECHO [101;1m
SET /P user="Informe o usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P pass="Digite a senha do usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P ramal="Digite o Ramal: "
ECHO [0m
ECHO.
ECHO [92mImplementando o SRC e configurando o Ramal, aguarde...[0m
RD /S /Q "\\%pc%\c$\Integrador"
RD /S /Q "\\%pc%\c$\NewSrc"
MD "\\%pc%\c$\Program Files (x86)\Borland\Common Files\BDE"
MD "\\%pc%\c$\Integrador"
MD "\\%pc%\c$\NewSrc"
XCOPY "C:\Suporte\SRC\SRC" "\\%pc%\c$\" /D/I/E/H/C/Y
COPY "C:\Suporte\SRC\BDE\*.*" "C:\Program Files (x86)\Borland\Common Files\BDE" /Y
COPY "C:\Suporte\SRC\ODBC\ODBC32.reg" "\\%pc%\c$\NewSrc" /Y
PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s regedit /s "c:\NewSrc\ODBC32.reg"
REM PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s "c:\NewSrc\ODBC32.reg" /y
powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini'
PAUSE
GOTO MENU
So I need to access an remote computer, copy some files and modify "Ramal=xxxxxx" lines in SRC.ini file
:SRC
CLS
ECHO.
ECHO [101;1m
SET /P user="Informe o usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P pass="Digite a senha do usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P ramal="Digite o Ramal: "
ECHO [0m
ECHO.
ECHO [92mImplementando o SRC e configurando o Ramal, aguarde...[0m
RD /S /Q "\\%pc%\c$\Integrador"
RD /S /Q "\\%pc%\c$\NewSrc"
MD "\\%pc%\c$\Program Files (x86)\Borland\Common Files\BDE"
MD "\\%pc%\c$\Integrador"
MD "\\%pc%\c$\NewSrc"
XCOPY "C:\Suporte\SRC\SRC" "\\%pc%\c$\" /D/I/E/H/C/Y
COPY "C:\Suporte\SRC\BDE\*.*" "C:\Program Files (x86)\Borland\Common Files\BDE" /Y
COPY "C:\Suporte\SRC\ODBC\ODBC32.reg" "\\%pc%\c$\NewSrc" /Y
PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s regedit /s "c:\NewSrc\ODBC32.reg"
REM PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s "c:\NewSrc\ODBC32.reg" /y
powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini'
PAUSE
GOTO MENU
So I need to access an remote computer, copy some files and modify "Ramal=xxxxxx" lines in SRC.ini file
Re: Help with characters replacement in a INI file and psexec command
Please use code tags (select </> button).
You should leave that
Code: Select all
goto :EOF
Saso
Re: Help with characters replacement in a INI file and psexec command
Adding some code blocks (as I am not the mod I can't change the original post):
SasoDasmius wrote: That is more like I need
Code: Select all
@echo off CHCP 65001 SETLOCAL ENABLEEXTENSIONS SETLOCAL ENABLEDELAYEDEXPANSION :menu CLS ECHO. ECHO. ECHO [104;93m ____________________________________ [0m ECHO [104;93m│ ********************************** │[0m ECHO [104;93m│ SUBMENU - Configuração SRC │[0m ECHO [104;93m│ ********************************** │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ 1 - Set SRC │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ 6 - Exit │[0m ECHO [104;93m│ RØÐRIGØ │[0m ECHO [104;93m│────────────────────────────────────│[0m ECHO. ECHO [101;1m CHOICE /N /C:12 /M "Escolha uma opção: " ECHO [0m if errorlevel ==2 goto EXIT if errorlevel ==1 goto SRC GOTO MENU :SRC set /p ramal="Digite o Ramal" (echo [SRC] )>new_ini.ini for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call :DOSOME "%%f" "%%g" goto :EOF :DOSOME set new_var=%~1=%~2 REM IF below is CASE SENSITIVE if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal% (echo %new_var%)>>new_ini.ini REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES PAUSE goto menu :EXIT EXIT
BUT, when I do it, the new_ini.ini file returns almos empyt inside of it, just with this lines inside of
What I'm doing wrong?Code: Select all
[SRC] DDD=11
Last edited by miskox on 25 Nov 2022 00:33, edited 1 time in total.
Re: Help with characters replacement in a INI file and psexec command
(adding code blocks)
Dasmius wrote: ↑24 Nov 2022 07:23That's what I'm doing actually
So I need to access an remote computer, copy some files and modify "Ramal=xxxxxx" lines in SRC.ini fileCode: Select all
:SRC CLS ECHO. ECHO [101;1m SET /P user="Informe o usuário administrativo: " ECHO [0m ECHO. ECHO [101;1m SET /P pass="Digite a senha do usuário administrativo: " ECHO [0m ECHO. ECHO [101;1m SET /P ramal="Digite o Ramal: " ECHO [0m ECHO. ECHO [92mImplementando o SRC e configurando o Ramal, aguarde...[0m RD /S /Q "\\%pc%\c$\Integrador" RD /S /Q "\\%pc%\c$\NewSrc" MD "\\%pc%\c$\Program Files (x86)\Borland\Common Files\BDE" MD "\\%pc%\c$\Integrador" MD "\\%pc%\c$\NewSrc" XCOPY "C:\Suporte\SRC\SRC" "\\%pc%\c$\" /D/I/E/H/C/Y COPY "C:\Suporte\SRC\BDE\*.*" "C:\Program Files (x86)\Borland\Common Files\BDE" /Y COPY "C:\Suporte\SRC\ODBC\ODBC32.reg" "\\%pc%\c$\NewSrc" /Y PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s regedit /s "c:\NewSrc\ODBC32.reg" REM PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s "c:\NewSrc\ODBC32.reg" /y powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini' PAUSE GOTO MENU
Last edited by miskox on 25 Nov 2022 00:33, edited 1 time in total.
Re: Help with characters replacement in a INI file and psexec command
And here is the reply to both posts:
And from another post:
Saso
Code: Select all
@echo off
CHCP 65001
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:menu
CLS
ECHO.
ECHO.
ECHO [104;93m ____________________________________ [0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ SUBMENU - Configuração SRC │[0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 1 - Set SRC │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 6 - Exit │[0m
ECHO [104;93m│ RØÐRIGØ │[0m
ECHO [104;93m│────────────────────────────────────│[0m
ECHO.
ECHO [101;1m
CHOICE /N /C:12 /M "Escolha uma opção: "
ECHO [0m
if errorlevel ==2 goto EXIT
if errorlevel ==1 goto SRC
GOTO MENU
:SRC
set /p ramal="Digite o Ramal"
(echo [SRC] )>new_ini.ini
for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call :DOSOME "%%f" "%%g"
REM your code goes here
REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE
REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES
REM I would suggest you use the current file name in your .bat which you can delete when you are done (so you don't loose your original .ini file)
goto :EOF
:DOSOME
set new_var=%~1=%~2
REM IF below is CASE SENSITIVE
if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal%
(echo %new_var%)>>new_ini.ini
goto :EOF
:EXIT
EXIT
Code: Select all
:SRC
CLS
ECHO.
ECHO [101;1m
SET /P user="Informe o usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P pass="Digite a senha do usuário administrativo: "
ECHO [0m
ECHO.
ECHO [101;1m
SET /P ramal="Digite o Ramal: "
ECHO [0m
ECHO.
ECHO [92mImplementando o SRC e configurando o Ramal, aguarde...[0m
RD /S /Q "\\%pc%\c$\Integrador"
RD /S /Q "\\%pc%\c$\NewSrc"
MD "\\%pc%\c$\Program Files (x86)\Borland\Common Files\BDE"
MD "\\%pc%\c$\Integrador"
MD "\\%pc%\c$\NewSrc"
XCOPY "C:\Suporte\SRC\SRC" "\\%pc%\c$\" /D/I/E/H/C/Y
COPY "C:\Suporte\SRC\BDE\*.*" "C:\Program Files (x86)\Borland\Common Files\BDE" /Y
COPY "C:\Suporte\SRC\ODBC\ODBC32.reg" "\\%pc%\c$\NewSrc" /Y
PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s regedit /s "c:\NewSrc\ODBC32.reg"
REM PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s "c:\NewSrc\ODBC32.reg" /y
REM the command below should be updated:
REM original command:
REM powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini'
REM new command. Check if it is OK. I guess '-replace' switch is not needed anymore, right? Is the location of the new_ini.ini correct?
powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\new_ini.ini') | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini'
PAUSE
GOTO MENU
Re: Help with characters replacement in a INI file and psexec command
Sorry about my misunderstand, but guess I got it now. So I left it like this and it's working (It's not my original batch, It's just an exemple that I was using to try explain what I need)miskox wrote: ↑25 Nov 2022 00:31And here is the reply to both posts:
And from another post:Code: Select all
@echo off CHCP 65001 SETLOCAL ENABLEEXTENSIONS SETLOCAL ENABLEDELAYEDEXPANSION :menu CLS ECHO. ECHO. ECHO [104;93m ____________________________________ [0m ECHO [104;93m│ ********************************** │[0m ECHO [104;93m│ SUBMENU - Configuração SRC │[0m ECHO [104;93m│ ********************************** │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ 1 - Set SRC │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ │[0m ECHO [104;93m│ 6 - Exit │[0m ECHO [104;93m│ RØÐRIGØ │[0m ECHO [104;93m│────────────────────────────────────│[0m ECHO. ECHO [101;1m CHOICE /N /C:12 /M "Escolha uma opção: " ECHO [0m if errorlevel ==2 goto EXIT if errorlevel ==1 goto SRC GOTO MENU :SRC set /p ramal="Digite o Ramal" (echo [SRC] )>new_ini.ini for /f "skip=1 tokens=1,2 delims==" %%f in (src.ini) do call :DOSOME "%%f" "%%g" REM your code goes here REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES REM I would suggest you use the current file name in your .bat which you can delete when you are done (so you don't loose your original .ini file) goto :EOF :DOSOME set new_var=%~1=%~2 REM IF below is CASE SENSITIVE if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal% (echo %new_var%)>>new_ini.ini goto :EOF :EXIT EXIT
SasoCode: Select all
:SRC CLS ECHO. ECHO [101;1m SET /P user="Informe o usuário administrativo: " ECHO [0m ECHO. ECHO [101;1m SET /P pass="Digite a senha do usuário administrativo: " ECHO [0m ECHO. ECHO [101;1m SET /P ramal="Digite o Ramal: " ECHO [0m ECHO. ECHO [92mImplementando o SRC e configurando o Ramal, aguarde...[0m RD /S /Q "\\%pc%\c$\Integrador" RD /S /Q "\\%pc%\c$\NewSrc" MD "\\%pc%\c$\Program Files (x86)\Borland\Common Files\BDE" MD "\\%pc%\c$\Integrador" MD "\\%pc%\c$\NewSrc" XCOPY "C:\Suporte\SRC\SRC" "\\%pc%\c$\" /D/I/E/H/C/Y COPY "C:\Suporte\SRC\BDE\*.*" "C:\Program Files (x86)\Borland\Common Files\BDE" /Y COPY "C:\Suporte\SRC\ODBC\ODBC32.reg" "\\%pc%\c$\NewSrc" /Y PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s regedit /s "c:\NewSrc\ODBC32.reg" REM PsExec \\%pc% -u "domainbr\%user%" -p "%pass%" -s "c:\NewSrc\ODBC32.reg" /y REM the command below should be updated: REM original command: REM powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\SRC.ini') -replace '12335','%ramal%' | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini' REM new command. Check if it is OK. I guess '-replace' switch is not needed anymore, right? Is the location of the new_ini.ini correct? powershell -Command "(Get-Content -Path '\\%pc%\c$\NewSrc\new_ini.ini') | Set-Content -Path '\\%pc%\c$\NewSrc\SRC.ini' PAUSE GOTO MENU
@echo off
CHCP 65001
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:menu
CLS
ECHO.
ECHO.
ECHO [104;93m ____________________________________ [0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ SUBMENU - Configuração SRC │[0m
ECHO [104;93m│ ********************************** │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 1 - Set SRC │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ │[0m
ECHO [104;93m│ 6 - Exit │[0m
ECHO [104;93m│ RØÐRIGØ │[0m
ECHO [104;93m│────────────────────────────────────│[0m
ECHO.
ECHO [101;1m
CHOICE /N /C:12 /M "Escolha uma opção: "
ECHO [0m
if errorlevel ==2 goto EXIT
if errorlevel ==1 goto SRC
GOTO MENU
:SRC
set /p ramal="Digite o Ramal"
(echo [SRC] )>"%temp%\temp.txt"
for /f "skip=1 tokens=1,2 delims==" %%f in (c:\SRC.ini) do call OSOME "%%f" "%%g"
powershell -Command "(Get-Content -Path '%temp%\temp.txt') | Set-Content -Path 'C:\Users\rpcastro\Desktop\SRC.ini'
GOTO menu
REM SUB ROTINA DE :SRC
OSOME
set new_var=%~1=%~2
REM IF below is CASE SENSITIVE
if "%new_var:~0,6%"=="Ramal=" set new_var=Ramal=%ramal%
(echo %new_var%)>>"%temp%\temp.txt"
REM HERE I NEED A COMMAND TO RENAME AND REPLACE THE OLD SRC.ini FILE
REM PAUSE HERE CUZ NEED TO CHECK ANOTHER PREVIOUS COMMANDS AND TRANSFER FILES
GOTO :EOF
:EXIT
EXIT
So basically I run an Batch on local computer that copy, register and configure some files at this PC, but I can't write or modify anithing at the server cuz the local PC's doesn't have permissions for that. So I decided to make it at the TEMP folder and use powershell to overwrite the new file on local computer.
So thank you very much for your patience and time