Computing.Net > Forums > Programming > Batch Scripting Command line Login

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Scripting Command line Login

Reply to Message Icon

Name: GeoffLilly
Date: November 15, 2005 at 01:34:23 Pacific
OS: Windows XP
CPU/Ram: 2.8
Comment:

Hi

I’m creating a login script, but having a little bit of trouble with this section.

The login script isn’t very flashy, but works all the time, just a few net views..etc.etc..

I thought to stop running this everyday for a user I would enter a registry key in current user

Something like this

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\login]
"loginscript"="1"

does anyone know a quick line in command line batch scripting that would say.

If [HKEY_CURRENT_USER\login]
"loginscript"="1" exists

goto end: of script?

I’ve looked at the tools that are provided, would reg query be the best, but then I’m not sure how to get the value 1 and if there drop the script out to the end.

Hope this makes sense..

Thanks in advance

Geoff



Sponsored Link
Ads by Google

Response Number 1
Name: Dr. Nick
Date: November 15, 2005 at 18:46:23 Pacific
Reply:

I think the easiest way to do this would be using this snippet from a login script:

REG ADD HKCU\loginTest /v loginscript /d 1 /f

REG COMPARE HKCU\loginTest HKCU\login /v loginscript

IF "%errorlevel%"=="0" EXIT

What it does is first create a test key (HKCU\loginTest). By setting it to a "1" we can then do a REG COMPARE and use the return value (stored in %errorlevel%) to determine if the HKCU\login is the same. If it is any other value or does not exist then %errorlevel% will not be equal to "0". So if
%errorlevel% IS equal to "0" then it means that HKCU\login\loginscript is equal to "1" and we can exit the script with the EXIT command.

How's that? You might need to change the registry key values if you want to check something besides HKCU\login.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Scripting Command line Login

Batch file command line args www.computing.net/answers/programming/batch-file-command-line-args/4226.html

Batch Script Command Help www.computing.net/answers/programming/batch-script-command-help/17339.html

Copy and rename with a batch script www.computing.net/answers/programming/copy-and-rename-with-a-batch-script/14966.html