Solved

Windows XP Reg Add function .

Posted on 2004-10-11
7
2,179 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now