Solved

Windows XP Reg Add function .

Posted on 2004-10-11
7
2,183 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
2 windows xp desktops computer 8 156
User laptop information 6 144
Upgrade or retire 8 96
XP machine unable to logon 13 61
Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

735 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