Solved

Convert Batch to VBScript

Posted on 2011-03-23
5
656 Views
Last Modified: 2012-06-27
hey can someone help me to convert this batch to vbscript for win 7?

1. reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /d Pelephone /f
2. net user Administrator /active:no
3. RD /S /Q "C:\Windows.old"


BTW if it's possible i want to be able to call the script with cscript SCRIPT.wsf  
thnx
0
Comment
Question by:siltech
  • 2
5 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 35203207
Hi, this is the converted code, but UAC will most likely get in the way for these actions.

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")

objShell.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "Pelephone", "REG_SZ"

strComputer = objNetwork.ComputerName
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
objUser.AccountDisabled = False
objUser.SetInfo

objFSO.DeleteFolder "C:\Windows.old", True

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35451758
LeeTutor, seeing as my code will work if UAC is disabled, and it's the only comment, it should be accepted as the answer.

Regards,

Rob.
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 35687867
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

777 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