#198874 - 2010-06-22 11:03 AM
Issue adding cmd.exe to registry
|
G0bi
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:
$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:
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
|
|
|
|
#198876 - 2010-06-22 11:52 AM
Re: Issue adding cmd.exe to registry
[Re: NTDOC]
|
G0bi
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
|
|
|
|
#198878 - 2010-06-22 12:14 PM
Re: Issue adding cmd.exe to registry
[Re: NTDOC]
|
G0bi
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
|
|
|
|
#198880 - 2010-06-22 01:16 PM
Re: Issue adding cmd.exe to registry
[Re: Glenn Barnas]
|
G0bi
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
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
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:
$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
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|