- upper
Code: Select all
cmd /D /E:ON /V:ON /C "@echo on&pushd "C:\Windows\Temp"&SET "KEY_NAME=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"&SET VALUE_NAME="Userinit"&(FOR /F \"USEBACKQ SKIP=2 TOKENS=1-4\" %A IN (`REG QUERY "!KEY_NAME!" /v "!VALUE_NAME" 2^>NUL`) DO (SET "VALUE_NAME=%A"&SET "VALUE_TYPE=%B"&SET "CURREGVALUE=%C %D"))&(IF DEFINED VALUE_NAME (>Userinitreg.txt ECHO !CURREGVALUE!&PAUSE >NUL&(IF "!errorlevel!" NEQ "0" (ECHO Copy reg record failed.&PAUSE >NUL))) ELSE (ECHO "!KEY_NAME!\!VALUE_NAME%! not found.&PAUSE >NUL))&POPD&PAUSE >NUL"
Code: Select all
cmd /D /E:ON /V:ON /C "@echo on&pushd "C:\Windows\Temp"&SET "KEY_NAME=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"&SET "VALUE_NAME=Userinit"&(FOR /F "USEBACKQ SKIP=2 TOKENS=1-4" %A IN (`CALL REG QUERY "!KEY_NAME!" /v "!VALUE_NAME!" 2^>NUL`) DO (SET "VALUE_NAME=%A"&SET "VALUE_TYPE=%B"&SET "CURREGVALUE=%C %D"))&ECHO HELLO&PAUSE >NUL"
With this, you should reread Aacinis posts.
Maybe it helps you to create oneliners this way:
1) Create a batch file (for example: "test.bat") that solves your task (to ensure that the logic is OK)
2) Copy this batch file to "test.txt".
3) Remove all that doesn't work in command line context (see first post); check the functionality of this command line script within a dos command shell:
Code: Select all
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. Alle Rechte vorbehalten.
Z:\><test.txt cmd
Code: Select all
(IF "a" == "a" (echo ok)else(echo not ok))
5) Add ampersands between Statements and create a single line; note that if you want to use extensions or delayed Expansion you have to execute this oneliner within one cmd Statement (as a Parameter; see above, see cmd /?):
Code: Select all
cmd /E:ON /V:ON /C "oneliner"
penpen