The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,737 other followers

Archive for January 16th, 2018

Provisioning Windows 7 test VMs with know users/passwords

Posted by jpluimers on 2018/01/16

The proxmox side

In Proxmox, ensure you have a named backup of your machine that starts with vzdump-qemu like this:

vzdump-qemu-Win7Sp1UK.vma.lzo

That way, Proxmox knows that it can restore from it.

Don’t forget to assign a new MAC address to the network adapter so it’s unique on the network.

The Windows side

I wanted to provision this with two test accounts: one regular and one with administrator access.

The latter needs to be added to the Administrators group using [WayBacknet localgroup.

Both need passwords that (for now) never expire. This is where [WayBacknet user add fails: even if you set the correct flag, it won’t be reflected, so you need WMIC UserAccount for that.

These two posts helped me a lot with the below batch file fragment:

After restoring, run a batch file like this with an UAC token:

  call :addUser regularTestUser regularTestPassword
  net localgroup "Remote Desktop Users" "regularTestUser" /add
  call :addUser administratorTestUser administratorTestPassword
  :: https://superuser.com/questions/515175/create-admin-user-from-command-line
  net localgroup administrators administratorTestUser /add
  goto :eof
:addUser
  :: https://superuser.com/questions/515175/create-admin-user-from-command-line
  net user /expires:never /add %1 %2 /expires:never
  :: https://serverfault.com/questions/710964/accounts-suddenly-expiring-when-created-with-net-user-add-expiresnever
  WMIC UserAccount where "Name='%1'" set PasswordExpires=FALSE
  goto :eof

The Remote Desktop Users tip is from [WayBackEnable remote desktop from command line (CMD) but that post has “beautified” double quotes in them, so net localgroup by default complains it cannot find the group. The code above should have regular quotes.

Finally the computer needs a new name. Again WMIC to the rescue here as Windows 7 only comes with PowerShell 2.0 which cannot rename a computer.

Again with a UAC token, execute something like this:

WMIC ComputerSystem where Name="%COMPUTERNAME%" call Rename Name=INNOSETUPTEST
%windir%\System32\shutdown.exe -r

This last tip was via [WayBackwindows 7 – Renaming computers via command prompt – Super User.

–jeroen

Posted in Power User, Proxmox, Virtualization, Windows, Windows 7 | Leave a Comment »

Changing component class at run-time on demand for older Delphi versions need a bit more magic than you’d expect

Posted by jpluimers on 2018/01/16

Just in case I ever need to do heavy Delphi 2007 magic to change the component class of an object instance:

[WayBack] Quite unusual compiler behaviour (for older compilers) as seen here:http://stackoverflow.com/questions/41181767/patching-instance-class-requires-base-… – David Heffernan – Google+

References:

–jeroen

Source: Quite unusual compiler behaviour (for older compilers) as seen here: http://…

Posted in Delphi, Delphi 2007, Development | Leave a Comment »

 
%d bloggers like this: