Solved

Convert Batch to VBScript

Posted on 2011-03-23
5
654 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 26
sync conflicts 1 20
Windows 7 Update hangs ... 7 30
Spell Check in VB6 13 42
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

17 Experts available now in Live!

Get 1:1 Help Now