Solved

Windows XP Reg Add function .

Posted on 2004-10-11
7
2,182 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:bRvO
  • 4
  • 3
7 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 12275356
I would suspect it's the space between Session Manager & Memory Management but have yet to find a suitable workaround for this problem.  Hope someone has an answer for you.
0
 
LVL 5

Author Comment

by:bRvO
ID: 12275635
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
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 500 total points
ID: 12275696
Not sure about that assetnumber, but it appears you have your ' before your +
would that cause the problem?

Also, how about adding in some quotations...

var cmdln = 'cmd /k reg add "\\\\'+assetnumber'+\\' + chr(34) + 'HKLM\\SYSTEM\\'+
                                           'CurrentControlSet\\Control\\'+
                                           'Session Manager\\Memory Management\\'+ chr(34) +
                                           '/v PagingFiles /t REG_MULTI_SZ /d C:\pagefile.sys\0256\0256 /f"';
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 5

Author Comment

by:bRvO
ID: 12275923
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 ... :)
0
 
LVL 5

Author Comment

by:bRvO
ID: 12276039
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>
0
 
LVL 5

Author Comment

by:bRvO
ID: 12276070
cheers for your help .... your comments provided me with that little bit extra that I needed to get the result .

thanks :D
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 12276170
Wow - thank YOU. : )
Happy to assist in any way I can.  Glad you got it working.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question