Link to home
Start Free TrialLog in
Avatar of bRvO
bRvOFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Windows XP Reg Add function .

Okay , here's my problem.

I run this command on a web page on windows NT machines and it works fine ... it doesnt work when you run it on XP machines tho :/

var cmdln = 'cmd /k reg update "HKEY_LOCAL_MACHINE\\'+
                 'SYSTEM\\CurrentControlSet\\Control\\'+
                 'Session Manager\\Memory Management\\'+
                  'pagingfiles"="C:\\pagefile.sys 256 256" '+''+assetnumber+'';

var shell=new ActiveXObject("WScript.shell");
shell.run(cmdln);

.. managed to figure out that there was no reg update function in XP ( wooh go me :/ ) , so changed the script slightly... to this :

var cmdln = 'cmd /k reg add "\\\\'+assetnumber'+\\HKLM\\SYSTEM\\'+
                                           'CurrentControlSet\\Control\\'+
                                           'Session Manager\\Memory Management\\'+
                                           '/v PagingFiles /t REG_MULTI_SZ /d C:\pagefile.sys\0256\0256 /f"';

var shell=new ActiveXObject("WScript.shell");
shell.run(cmdln);

but recieve the error : invalid Key name

ignore the '+assetnumber+' please as this is part of another script in the page ... I have however removed it from the page to try the command and still recieve the error ..

this command works in a command prompt window : reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v PagingFiles /t REG_MULTI_SZ /d C:\pagefile.sys\0256\0256 /f

anyone any idea's as to how i'm entering the incorrect syntax for this. ?? thanks in advance much appreciated.
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bRvO

ASKER

That's what I thought too , as when i entered it in the command prompt window , I had to enclose the key in "" to get it to work ... not sure on how i can resolve it though ... have tried enclosing the lot in "" or even ' ' , same error each time :/

cheers anyway :x
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bRvO

ASKER

yeah , that would cause a problem with adding the asset number .. if managed to get it to work without the assetnumber part ...

this is what i used

car cmdln = 'cmd /k reg add "HKLM\\SYSTEM\CurrentControlSet\\Control\Session Manager\\Memory Management" /v PagingFiles /t REG_MULTI_SZ /d "C:\pagefile.sys 1024 1024" /f';

that changes the Virtual Memory on any XP machine that runs the web page...

just got to add the assetnumber part now :o

thanks for your help ... :)
Avatar of bRvO

ASKER

done it . pretty simple really :/

var cmdln = 'cmd /k reg add "\\\\'+assetnumber+'\\HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management" /v PagingFiles /t REG_MULTI_SZ /d "C:\\pagefile.sys 1024 1024" /f';


(all one line )

when the prompt appears as the page loads ... just enter the netbios/ip address of the remote machine and click ok ... comman completed succesfully appears . checked the remote machine and it works.

for anyone who's interested .. the local machine needs to have ActiveX enabled ( all settings )

and this needs to be in the page header

<html>
<head>




var assetnumber= prompt('please enter asset number',' ');

if ( (assetnumber==' ') || (assetnumber==null) )
 {
      assetnumber="ERROR";
 }



</head>
Avatar of bRvO

ASKER

cheers for your help .... your comments provided me with that little bit extra that I needed to get the result .

thanks :D
Wow - thank YOU. : )
Happy to assist in any way I can.  Glad you got it working.