Batch file not running correctly

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Batch file not running correctly

Post by carelvos » Thu Oct 08, 2015 9:02 am

I have the following code:

set the hideConsoleWindows to false
get shell("C:\aa87275\regadd.bat")
if it is not empty then answer it

Inside the regadd.bat is the following:

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Run\ /t REG_SZ /v "test" /d "C:\Windows\test.exe" /f
echo xxx >> c:\test.txt

In the console window the reg add command says The operation completed successfully and the xxx gets added to c:\test.txt, so the batch file do run, but the registry does not get updated. When I run the batch file from explorer the registry does get updated. I did try to run livecode as administrator - same thing.

Any ideas?

Thanks,

Carel

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Batch file not running correctly

Post by FourthWorld » Thu Oct 08, 2015 9:40 am

You might try LiveCode's built-in setRegistry function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Batch file not running correctly

Post by carelvos » Thu Oct 08, 2015 10:17 am

I did try the setRegistry but couldn't get it to work. Do you maybe have an example?

Thanks,

Carel

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Batch file not running correctly

Post by LCNeil » Thu Oct 08, 2015 10:44 am

Hi Carel,

Its sounds like you are running a 64bit version of Windows?

LiveCode is a 32bit application so any registry calls will be written to the Wow6432Node registry entry. This is taken care of automatically by Windows.

More info on this can be found here-

http://www.advancedinstaller.com/user-g ... -node.html

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
-

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Batch file not running correctly

Post by carelvos » Thu Oct 08, 2015 11:27 am

LCNeil wrote:Hi Carel,

Its sounds like you are running a 64bit version of Windows?

LiveCode is a 32bit application so any registry calls will be written to the Wow6432Node registry entry. This is taken care of automatically by Windows.

More info on this can be found here-

http://www.advancedinstaller.com/user-g ... -node.html

Kind Regards,

Neil Roger
--

LiveCode Support Team ~ http://www.livecode.com
-
Hi Neil,

Yes you are right, the key is there.

Thanks,

Carel

SparkOut
Posts: 2945
Joined: Sun Sep 23, 2007 4:58 pm

Re: Batch file not running correctly

Post by SparkOut » Thu Oct 08, 2015 11:30 am

Might it be running foul of requirement for elevated permissions to run the shell command?
I haven't played with the registry for a long time, since XP days.
I have just tried with Windows 7 32 bit edition, cannot get either the batch file way or setRegistry way to work.
If I open a command prompt by right-clicking and "run as administrator" I can put the reg add line in and it will work. Without elevated permissions it produces ERROR: Access is denied.
Is there a way to elevate permissions to run the setRegistry command within LC, in the IDE or a stack - I know there is a manifest option in the standalone settings.

[EDIT] I see you have had success with the 32 bit node. Are you running Windows XP?

[Another EDIT] Opening the IDE with "Run as Administrator" works to setRegistry too, der!

carelvos
Posts: 19
Joined: Tue Jul 14, 2015 5:21 pm

Re: Batch file not running correctly

Post by carelvos » Sat Oct 10, 2015 9:45 am

SparkOut wrote:Might it be running foul of requirement for elevated permissions to run the shell command?
I haven't played with the registry for a long time, since XP days.
I have just tried with Windows 7 32 bit edition, cannot get either the batch file way or setRegistry way to work.
If I open a command prompt by right-clicking and "run as administrator" I can put the reg add line in and it will work. Without elevated permissions it produces ERROR: Access is denied.
Is there a way to elevate permissions to run the setRegistry command within LC, in the IDE or a stack - I know there is a manifest option in the standalone settings.

[EDIT] I see you have had success with the 32 bit node. Are you running Windows XP?

[Another EDIT] Opening the IDE with "Run as Administrator" works to setRegistry too, der!
Hi SparkOut

I'm on 64 bit Win 7 - From the IDE (without running as Administrator) the batch file works but goes to the 32 bit node. On Windows 8 running the standalone (no livecode on that PC) as Administrator, the batch file does not run - or I should say it probably runs, but isn't running as Administrator although it is called from my app that is running as Administrator. That is just purely speculation though.

Anyone got an example for setRegistry that works?

In the dictionary is the following examples:

setRegistry("HKEY_CLASSES_ROOT\.txt\", "NotePad")
if setRegistry(myEntry & "/",myValue) then open file myFile
setRegistry(theKey,empty)

but it says setRegistry is a FUNCTION, so what should the correct way be to use it??

Regards,

Carel

Post Reply