Page 1 of 1 1
Topic Options
#198874 - 2010-06-22 11:03 AM Issue adding cmd.exe to registry
G0bi Offline
Fresh Scripter

Registered: 2010-06-22
Posts: 5
Loc: Baden-Württemberg, Germany
Hi all,

i want to add a commandline to registry. My Code is:
 Code:
$SUCCESS = 0
If ExistKey("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run") <> $SUCCESS
If AddKey("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run") <> $SUCCESS
? "AddKey failed with error code (" = @ERROR + ")"
Exit @ERROR<>0
Endif
Endif
If InGroup ("DENBG_All")
If WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","RunBGInfo","cmd.exe /c BGInfo\BGinfo.exe BGinfo\denbgAll.bgi /TIMER:0 /NOLICPROMPT","REG_SZ") = $SUCCESS
	? "Value written to registry successfully"
Else
	? "WriteValue failed with error code (" + @ERROR + ")"
Exit @ERROR<>0
Endif
Endif


The main part is this:

 Code:
If WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","RunBGInfo","cmd.exe /c BGInfo\BGinfo.exe BGinfo\denbgAll.bgi /TIMER:0 /NOLICPROMPT","REG_SZ") = $SUCCESS

but here I should insert following to this reg key or it does not work

"cmd.exe /c "BGInfo\BGinfo.exe BGinfo\denbgAll.bgi" /TIMER:0 /NOLICPROMPT"

and the quotation marks (here bold) does not work. Kixtart tells an error that it is missing commas.If I delete these, the command will not work.

The Idea is to run bginfo every time local, so it would also work if the notebooks have no network connection.

Any ideas?

Thank you very much
Stefan

Top
#198875 - 2010-06-22 11:17 AM Re: Issue adding cmd.exe to registry [Re: G0bi]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
You would need to delay your script until after the desktop loads or use run once to load later on. That registry key does not exist during the logon process.
Top
#198876 - 2010-06-22 11:52 AM Re: Issue adding cmd.exe to registry [Re: NTDOC]
G0bi Offline
Fresh Scripter

Registered: 2010-06-22
Posts: 5
Loc: Baden-Württemberg, Germany
Hi NTDOC

I know that it would not exist during logon, but it would exist after the second login. That is not the main problem. Maybe I ask if the value already exist before write it to registry.

Thank You


Edited by G0bi (2010-06-22 11:53 AM)

Top
#198877 - 2010-06-22 12:04 PM Re: Issue adding cmd.exe to registry [Re: G0bi]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hello,

Try doing it locally while logged on and alter the outcome to test back and forth. Make sure your If InGroup is working as expected as well.

Top
#198878 - 2010-06-22 12:14 PM Re: Issue adding cmd.exe to registry [Re: NTDOC]
G0bi Offline
Fresh Scripter

Registered: 2010-06-22
Posts: 5
Loc: Baden-Württemberg, Germany
it is really doing well, the only problem i have is that kix does not understand that i need the quotation marks and does interpret these wrong. If I delete the quotation marks the key will be successfull added. I could also just call a batch, but i want to call the command directly

Thank you

Top
#198879 - 2010-06-22 12:40 PM Re: Issue adding cmd.exe to registry [Re: G0bi]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Try using single quotes where KIX wants the quotes, and double-quotes inside those where the parameter wants them.
 Code:
WriteValue('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run','RunBGInfo','cmd.exe /c "BGInfo\BGinfo.exe BGinfo\denbgAll.bgi /TIMER:0 /NOLICPROMPT"','REG_SZ') 
I always use single quotes for Kix so that commands that require double quotes will work.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#198880 - 2010-06-22 01:16 PM Re: Issue adding cmd.exe to registry [Re: Glenn Barnas]
G0bi Offline
Fresh Scripter

Registered: 2010-06-22
Posts: 5
Loc: Baden-Württemberg, Germany
Thank you Glenn,

that was the solution!! ;\)

I will show the whole script when i am finished.

Stefan

Top
#198881 - 2010-06-22 01:43 PM Re: Issue adding cmd.exe to registry [Re: Glenn Barnas]
G0bi Offline
Fresh Scripter

Registered: 2010-06-22
Posts: 5
Loc: Baden-Württemberg, Germany
One more question,

how could it be done, that the script check if the Value in this key exists and if not do something.

Thank You

Stefan

Top
#198882 - 2010-06-22 01:54 PM Re: Issue adding cmd.exe to registry [Re: G0bi]
kelp7 Offline
Starting to like KiXtart

Registered: 2002-08-12
Posts: 124
Loc: UK
Hi

I recently made a script that checked a registry key's value for the build number of novell groupwise and then do something if it was a certain build, my code was just:

 Code:
$x = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Novell\GroupWise","BuildNumber")

IF $x >= 3007

	REM THIS IS WHERE YOU WOULD DO WHAT YOU WANT IT TO DO

ENDIF

Top
#198883 - 2010-06-22 01:58 PM Re: Issue adding cmd.exe to registry [Re: G0bi]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Code:
If ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run","RunBGInfo")
   "Value is in registry."+@CRLF
Else
   "Value is not in registry (or is empty)"+@CRLF
EndIf

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.064 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org