4 January 2013

I was building a more involved function the past couple of days for gathering data from a PC in the enterprise should troubleshooting be necessary.  The type of company I work for doesn’t always allow us to stay on the PC and troubleshoot an item (unless it’s a total blocker) so being able to gather a broad range of data is necessary to really troubleshoot since we can’t be on the machine.  Part of that function is retrieving hard drive information.  I’m only gathering a few pieces of info, but since PC’s can have multiple drives I needed a good way to manage each disk separately.  I could have done it with the following line of code, but as you can see from the screenshot, it’s messy and the numbers output are in bytes which isn’t useful at first glance.

gwmi -class win32_logicaldisk | Where {$_.DriveType -eq 3 -OR $_.DriveType -eq 4} | select -property DeviceID,Size,FreeSpace

gwmi

 

The big thing is to convert those numbers into something more meaningful.  I also don’t like the clumped output and wanted to be able to handle each disk separately and call any of it’s properties without additional formatting (to see what I mean, run that code and then try pulling just $var.DeviceID and you’ll see all the hashtable @ and{} characters… it’s a mess).  I decided to create the hashtable myself.  Since there could be multiple disks I also needed it to really be more like an object.  That’s where nesting my hashtables came in.  My other requirement, dynamically creating variables, comes from wanting to return all of my unknown-beforehand-number-of-disks within the same variable, but needing a way to make unique hashtable key names ($return.Disk1… , $return.Disk2… , etc).  It sounds confusing, so here’s the code:

Function getHD($strComputer) {
	# Retrieves hard drive information
	$return = @{}  # declare our return variable as a hashtable so it doesn't get created as a string
	$i = 0  # counter and dynamic part of variable for disks
	$hd = gwmi -comp $strComputer -class win32_logicaldisk
	ForEach ($disk in $hd) {
		If ($disk.Drivetype -eq 3 -OR $disk.DriveType -eq 4) {   # only return physical hard drive and network drive types (5 is CD)
			$i++
			$return.numDrives = $i # where I store the number of drives found so I can use that to iterate through them all later
			$return += @{
				"Disk$i" = @{ # new hashname must be in quotes so variable will be expanded
				DriveLetter = $disk.DeviceID
				Size = $disk.Size/1048576   # Convert to MB
				FreeSpace = $disk.FreeSpace/1048576   # Convert to MB
				}
			}
		}
	}
	return $return
}

 

  1. First, I declare my return variable as a hashtable so that if I wanted to store a certain bit of info at the root of it, it wouldn’t be a string.
  2. Next I declare the variable (a counter) that will be the dynamic part of my nested hashtable key name.
  3. Get the actual info, as objects with properties.
  4. Start my loop
  5. I only want physical hard disks and network drives to return, so I’m limiting what objects I actually look at based on their DriveType.  3 is physical, 4 is network.
  6. Note I’m not starting to count up on my counter until I have a match of a disk type I want.  This keeps my numbers continuous, with no gaps in the numbering for the final output.
  7. Next I’m setting my hashtable key that stores the value of the number of drives returned
  8. Now I’m adding a new (nested) hashtable to my $return hashtbale.  I do this by using the += to say I’m adding to and not replacing my hashtable, and then saying that what I’m adding is actually a hashtable itself by folling the += with the @{
  9. Now, inside the hashtable declaration, I’m creating the dynamic hashtable itself.  Note that the hashtable name is in quotes, if I didn’t use the quotes powershell would error.  Putting it in quotes causes the $i to expand to whatever it’s value is.  Thus, for each iteration it changes:  Disk1 = @{…}, Disk2=@{…}, etc
  10. Then the next few lines are me setting the key names for each disk, example:  Disk1.DriveLetter = $disk.DeviceID
    1. You can’t do this symply by typing out Disk$i.DriveLetter = $disk.DeviceID. Reason being the Disk$i is not in quotes and you can’t use . notation if it is in quotes.  (This does not work:  “Disk$i”.DriveLetter = whatever)
    2. The math in there is just me converting bytes to MB… I know, nowadays what drives aren’t in GB but that’s easy to see from MB.
  11. And then finally I return the entire $return hashtable.

So now what?  I call my function by:  $hdinfo = getHD $pc      Then I run through that returned hashtable “object” and output the data to a file.  That is just a few simple lines:

For ($i=1; $i -le $hdInfo.numDrives;$i++) {
     $hdvar = "`$hdinfo.disk$i"
     invoke-expression $hdvar | Out-file $global:consolePath\PCData\$pc\PCVitals.txt -append -noclobber
}

 

  1. I’m starting a for loop that starts at 1 (Disk1) and will keep adding up until I get to the the number of drives that I stored in that key numDrives.
  2. Next I have to dynamically retrieve that dynamically named variable.  To do that I have to set a variable to be the name of the variable since I have to expand again.  Putting the ` infromt of $hdinfo keeps it from expanding that part.  I want to keep that part of the name literal since I dont want it’s value yet.  Since I know the exact number and how the naming convention goes, I just use my $i counter and put it in the part where it belongs:  disk$i.  The resulting value of $hdvar ends up being “$hdinfo.disk1” (2,3,4, etc).  But it’s a string value, not the object/hashtable itself.  that’s why….
  3. In the last line I’m calling invoke-expression because it’s a cmdlet that tells powershell to take the contents of the variable passed to it and treat it like it’s a command that was typed at the prompt (i.e. it will convert the string to a command).  And I’m pipping it out to a file.
    1. The other thing that wont work is piping your hashtable directly to the out-file.  Your resulting file will end up just having System.Whatever.Hashtable or something like that as it can’t figure out how to convert the output so it just outputs the object type.

And what does it all look like?

Name                           Value                                                                                   
----                           -----                                                                                   
FreeSpace                      1171586.5703125                                                                         
DriveLetter                    C:                                                                                      
Size                           1437513.9921875                                                                         

Name                           Value                                                                                   
----                           -----                                                                                   
FreeSpace                      1143174.359375                                                                          
DriveLetter                    D:                                                                                      
Size                           1423843.99609375                                                                        

Name                           Value                                                                                   
----                           -----                                                                                   
FreeSpace                      1034453.83984375                                                                        
DriveLetter                    E:                                                                                      
Size                           1430727.99609375

I could do a little more formatting if I wanted, but this is good enough for me!  And if I wanted to further use that data in a function it’s easy to reference an individual item with just $hdinfo.Disk1.FreeSpace or $hdinfo.Disk2.Size


20 November 2012

I need to vent a little before I get into the code.  Had a frustrating one today!  All because of unclear documentation in MSDN’s published library of their .NET classes. I guess it’s true what they say, that sometimes you should listen to what isn’t said.

I had to build a work-around to a problem with an MSI from a certain cardiovascular imaging software.  It seems the MSI wants to strip the permissions for the local “Users” group off of the C:\ProgramData folder.  Not cool!  At first the vendor tried to brush it under the rug and gave me a few lines about the development process, blah, blah (develoment?!  you’re just fixing the installer!) and then said it could take 10-12 weeks (which is further out than our very-rushed go-live) and if I could just work around it.  Did I mention this isn’t a lesson in customer service skills?

So anyway, I sat down to figure out how I was going to do it.  I’ve lost a lot of my VB skill because I haven’t used it in over 6 months and I’ve been learning a lot of Powershell.  I love Powershell and I’ve already written code to modify permissions (on a file on XP) so I figured this would be easy.  The one good thing I had going is the issue is only affecting Windows 7 so running the Powershell script locally isn’t a problem (we never pushed PS out to our XP devices).  What I thought would be a 5 minute mod of my existing code turned out to be about 30-40 minutes.

It seems just supplying the user/group (IdentityReference),  read/write/etc (FileSystemRights), and Allow/Deny (AccessControlType) were enough… but not really.   Mine was set to:

 

$Ar = New-Object  system.security.accesscontrol.filesystemaccessrule("Users","ReadAndExecute","Allow")

When setting just those three properties the permissions got applied but if you right-clicked on the folder and viewed the Security tab of the folders properties you saw a blank list of rights for that user/group.  All except for “Special Permissions” at the bottom.  If you went into advanced and dug a little deeper you could see that the Traverse folder/ execute file, List folder/read data, Read attributes, and Read extended attributes were all selected.  Read permissions was not.  Kind of a problem.  Below is what that looked like.

The other problem is it says “Apply to:  Subfolders and files only”.  With the changes not applying to the root folder I actually made the changes on, and not having proper read permissions, I have a funky looking ACL.  The odd thing is that the permissions I was wanting to apply worked.  Someone who fell into the “Users” group was able to read and execute like I wanted.  But, it’s technically broken so it needed to be fixed.

So I called up the MSDN library to find out what else I might need.  This post is already longer than it needs to be so it will suffice to say that I fiddled around with the InheritanceFlags Enumeration and PropagationFlags Enumeration parameters for quite a while.  I assumed the the FileSystemRights could be comma-separated since there were many options and you could have multiple.  I tried that and it worked, I got the “Read Permissions” checkbox back on the advanced properties view.   Still, the ACL was blank on the Security tab (with the exception of Special Permissions).  that took setting the Inheritance and Propagation flags correctly.  Both of these flags apply ONLY to the child object.  They do not affect whether the folder you are making changes to will inherit from it’s parent.  Inherit determinse whether the child object(s) inherit from the folder you are making changes on and propagate is what it pushes them down to.  Propagate is dependent on Inherit.

Ok, finish this up already.  Since I needed to put permisions back to default so that All Users/Public can appropriately access that folder I needed both file and folders to inherit.  And the kicker (reading what isn’t said…) is that the Propagation flags have to be set to None.  Why?  Because it doesn’t mean it wont propagate, it means it’s going to use the default value for propagation, which is:  This folder, subfolders, and files!  But the documentation does not say that anywhere!  It finally dawned on me that, that is what it would do.  So, my final code for adding “Users” to the ACL for the C:\ProgramData folder with Read and execute, List folder contents, and Read permissions is:

 

$Acl = Get-Acl C:\ProgramData
$Ar = New-Object  system.security.accesscontrol.filesystemaccessrule("Users","ReadAndExecute,Read","ObjectInherit,ContainerInherit","None","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl C:\ProgramData $Acl

Line 1 I’m getting the ACL of the object I want to modify
Line 2 I’m creating a new access rule and setting all of the parameters.  The local Users group, the TWO FileSystemRights, the Inheritance Flags (so that folders and files inherit), the Propagation flag (none means use default), and finally that I”m Allowing access and not Denying.
Line 3 I’m taking that access rule and adding it to the ACL object I created from the folder
Line 4 I’m actually setting the new ACL [in stone]

Yes, all that for 4 lines of code.

“Special” thanks to the MSDN library:  http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemaccessrule.aspx


16 November 2012

Bleh!  I’ve been so busy with the new position I started in April I’ve fallen off posting on this blog.  I have a lot of Powershell stuff I want to post—creating progress/activity bars, hashing, and perhaps a series on creating a simple text console.  I’ve also not been paying attention to replies, sorry!  I get so much spam from this blog that Gmail started dumping all my email alerts to comments in my spam box, which I never check.  I did respond to a couple, though… and realized I REALLY need to build-out the styling of the reply section and add the functionality to reply to comments!

Anyway, I just wanted to drop this quick and easy one here that I had to figure out last night.  I tried googling a solution for batch conversion last night when I needed to convert about 40 flv’s to mp4.  The web yielded nothing too great.  One site had a Powershell script but it didn’t work.  So, I just took from it what parameters I had to pass to the VLC application and wrote my own script.

This script has to be run from the directory where the videos are and it outputs them to the same directory.  I’m using Powershell 2.0 on Windows 7 Ultimate with VLC 2.0.4

$fileItems = Get-childitem -filter *.flv

ForEach ($file in $fileItems) {
$destination = “$($file.fullname).mp4”
start-process “C:\Program Files (x86)\VideoLAN\VLC\vlc.exe” “-I dummy -vvv “”$($file.fullname)”” `
–sout=#transcode{vcodec=h264,vb=1024,acodec=mpga,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=””$destination””} vlc://quit” -wait
}

The parts:

  • $fileItems = Get-childitem -filter *.flv
    • get’s all of the items in the folder that end in .flv (this is why you have to run it in the same folder, I was too lazy that late at night to put in an Open Dialog box 😉 )
  • ForEach ($file in $fileItems) {
    • begins our For loop that basically says “For each file you found in your enumeration results, do the following”
  • $destination =”$($file.fullname).mp4″
    • creates the full-path file name we are SAVING the file as.  I found it necessary to put the full path and set it in a variable because VLC didn’t like it otherwise.  I suspect because the VLC executable is in another directory than the files.  .fullname is a property of the object that is returned that is the fully-qualified path of the file.  If you want to modify anything and just want to use the filename (including extension) then it’s just .name
  • start-process “C:\Program Files (x86)\VideoLAN\VLC\vlc.exe” “-I dummy -vvv “”$($file.fullname)”” ` –sout=#transcode{vcodec=h264,vb=1024,acodec=mpga,ab=192,channels=2,deinterlace}:standard{access=file,mux=ts,dst=””$destination””} vlc://quit” -wait
    • Is technically one line.  The backtick (`) tells Powershell the command continues on the next line.
    • To be honest I don’t know what all the parameters do that are being passed to VLC but I do know the important ones:  vcodec is the name of the video codec you want to use to encode, vb is the video bitrate you want to encode at, acodec is the audio codec you want to encode with, and ab is the audio bitrate you want to encode at.   Channels is the number of audio channels.  dst is the destination file you want to save to.
    • Notice I have $destination surrounded in double quotes.  This is so when powershell actually passes that string to VLC it will put quotes around the destination file string.  This is necessary in the event you have spaces in your path and/or filename itself.  The vlc://quit tells VLC to exit when it’s done transcoding that file.  The -wait tells powershell to not go on to the next one until that current one is complete (lest you crash VLC…

Hope this saves someone some time 🙂


16 July 2012

Realized I still haven’t posted about the specs of the new PC I built back in mid May.  So here’s a quick post to get that out:

CPU:  Intel Core i7-3770K Ivy Bridge 3.5GHz
MB:  ASUS P8Z77-V Deluxe
Graphics:  NVidia GeForce GTX 560 Ti FPB (EVGA, 1GB of 256bit DDR5)
HD:  2 x Seagate Barracuda 3TB, 7200 RPM (ST3000DM001)
RAM:  16GB of GSkill Ripjaw X series DDR3 1600 (2 x 8GB)
Power:  Corsair 650TX
Optical:  Asus DVD-R/W drive (DRW-24B1ST, Black)
Case:  Thermaltake Chaser MK-I

I haven’t really put it to the test yet, although it plays WoW just fine.  Occasionally I have some chop but I’m not sure if it’s my PC.  The Witcher plays nicely, haven’t noticed any chop in that unless I have the graphics cranked way up, which shouldn’t be.  I should put Crysis on it soon and see how it does at full graphics.

With HT I love the fact that I have “8” cores.  All the RAM is nice, too.  I have an Ubuntu Server running right now that I’m setting my own personal WoW server up on and Wrath of the Lich King is installing on another VM that’s running.  All the while not bogging down my desktop!  PC runs fairly cool, idles at 37C (with stock cooler).  With WoW running I think it’s in the mid to upper 40’s.  Max safe operating temp is 67.4C so I have plenty of room.  The other thing that is completely amazing is that the fans are so quiet I honestly don’t even know it’s on.  The first morning I got up after having powered off the old machine I had to check to make sure the new one was on it, it’s dead silent.  Even if I sit here and focus on the machine and try to hear something I dont… unless I turn the chasis fans up to high then all I hear is the gentlest white noise.

Apps load pretty quick (Outlook 2010 is about 10 seconds.. iTunes, FF and others are almost instant).  Overall I’m pretty darn pleased!


19 May 2012

My nostalgia for old computer software/equipment put a bug in my head to get the old Win98 screensavers.  Specifically, “Mystery.”  I was greatly disappointed by the fact that Win98 native didn’t support more than 16 colors and a 640×480 resolution (I was further disppointed by the fact that Win7 can’t run the old screensavers!  Ugh!).

I kept googling for generic drivers that would allow me to up my color and resolution.  I finally found the “bear” drivers for windows.  I hard tried SciTech Display Doctor but I couldn’t get it to work properly.  It either didn’t let me boost the color to what it should be or caused the entire VM to lock up after I booted into it.  Not to mention, it’s only a trial!  The problem is the driver wont work (right) with the un-patched install from the CD.  MS doesn’t support the OS so you can’t update from their site, either.  Luckily, there is a kind fellow who has provided a “Service Pack” of updates for the OS and has made it available for DL.  Below are the steps to go through to get your Win98 patched, video quality improved, and sound working.

  1. Install the “Service Pack” from here:  http://exuberant.ms11.net/98sesp.html
  2. Reboot
  3. Install the display drivers from here: http://bearwindows.boot-land.net/vbe9x.htm#2
    1. The version I used (current as of this post) 2010.06.01
    2. If you didn’t install the service pack, Windows wont be able to “see” this driver and install it.
    3. To install:
      1. Download and extract
      2. Open your monitor via Device Manager (right click My Computer and select Properties)
      3. On the details for your monitor (display adapter) select to update the driver
      4. I skip having Windows search for it and just go straight to the VBEMP.DRV file under the VBE9X\UNI folder
  4. Reboot
  5. You should now be able to open your Display Properties and change your color to 32 bit and your resolution up to 1600×1200.  I run mine at 800×600 🙂

If you’re having trouble getting these files onto the Win98 VM (since it doesn’t support Guest Additions and therefore no folder sharing with the host) you have a few options.  You can burn a CD or use an FTP program like I did.  I have my own domain (duh!) so I uploaded the files there.  CoreFTP has a fairly navigable web page and it has a version that supports Win98, oh and it’s free!  When you go to download the page renders pretty bad from whatever file service they use but it’s manageable.

Info on getting your sound to work (selecting Soundblaster 16 in the Audio config for the VM) can be found here:  https://forums.virtualbox.org/viewtopic.php?t=9918

Huge thanks to the folks at the places above for putting these things together!


17 May 2012

So I built a new PC this week!  I’ll post more about that later, for now I want to document how I got booting the Windows 7 install in UEFI working so that I can take advantage of my whole 3TB drive and not just 2TB of it!

The UEFI “BIOS” comes pre-config’d for UEFI so I didn’t think I needed to do anything.  I installed windows by all the defaults in the wizard.  Then I realized that 764GB of my drive was unallocated and it wouldn’t let me create a partition!  I know I had read that Windows 7 supported the larger drives so I hopped on the net to try and figure out what was going on.  Turns out you have to explicity boot UEFI so I hopped into the setup utility to configure that.  For those of you who had already installed Windows, there will be an extra few steps to convert the drive.

  1. Turn on the PC and plop in the Windows 7 CD (or wait until you restart after uefi changes)
  2. Press the [Del] key to enter setup
  3. The main screen, which is the EZ setup, should have your bootable devices listed along the bottom.  You drag and drop them to change the order.  The one you’re looking for will be an icon for a hard drive (looks like an iPod).  It should have UEFI P3 and ASUS in the name.  Mine was stated as being 44XXMB.  Not sure what it was reading as 4.5GB but ok..
    1. It should really be the only UEFI listed.  If you’re like me, however, you might have a USB stick plugged in you forgot about and it will recognize this as a UEFI bootable device!  It’s icon was represented as a CD drive (for removable media)
  4. After moving your UEFI to the front of the boot order, go ahead and exit (button in top right) and save and restart.
  5. It should automatically starting loading the Windows CD after POST.
  6. Once it’s up to the first screen we need to make sure the drive is set to GPT (otherwise Windows can only use the first 2 TBs).  To do that press [SHIFT] + F10 which will open a command prompt
  7. Type DISKPART and hit [Enter]
  8. Type list disk and hit [Enter]
  9. It should display a list of all of your drives.  At the end of the row for each drive is a GPT column and there should be a * in it.  If not we need to convert it.
    1. Type select disk # where # is the number of the drive in the list.  If you’re not sure what drive is the one you want to install on, check the amount of space or, go to step 12 to see more details about the drive before making a choice.  That screen may tell you what is installed on other drives, but I”m not sure since I didn’t have any others.
    2. Type convert gpt and hit [Enter]
      1. If you did like me and already installed on this drive (or this drive was previously used and has volumes on it) you want to clear those first.
        1. After selecting disk, type clean and hit [Enter] to remove any volumes on the drive.  Then go back and convert to gpt
  10. If the drive was already GPT then skip to the next step, if you had to convert, reboot the PC and it should boot UEFI and start setup again.
  11. Once it’s back up go through the steps.  I don’t recommend doing an upgrade, I would select Custom Install  and start clean.
  12. Once you get to the screen to select the drive you want to install on, you should see your drive in it’s full capacity.
  13. Click on the Advanced options
  14. We want to create a new partition so select the drive and click New
    1. If you see a warning about not being able to install to that drive just ignore it as long as you get past the next step and can click next.
  15. Windows will warn you about making additional partitions.  According to my citation below it’s normal, necessary, and don’t touch it!
    1. The ones you see should say (System), (MSR)), and (Primary) next to them.  If your last one does not say (Primary) and it’s just blank, then setup was NOT run with UEFI and it’s setting up the disk as MBR instead of GPT.  Follow the steps for converting again and then reboot.
    2. Once you’re up and running in windows you can make as many logical drives as you want, so I wouldn’t worry about partitioning further here.
  16. You want to make sure the disk labeled Primary is the one you have selected and then continue on.
  17. Then just go through with the installation.

I was getting frustrated after reading MS’s article about converting the drive.  No where in the ASUS manual (or that I could find online) talked about what explicitly to do to make sure you were booting UEFI.  Thankfully I found the sites below to make the rest of my process easier after figuring that stuff out.

http://support.microsoft.com/kb/2604034
http://www.sevenforums.com/tutorials/186875-uefi-unified-extensible-firmware-interface-install-windows-7-a.html

 


2 May 2012

UPDATE 01/30/2014

There is a registry hack in Windows 7 to enable this feature again (although I wouldn’t necessarily suggest it… MS doesn’t support it).
You can naviGate to HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}  and clear out the value for RunAs.  This will enable the ability to do a runas and have explorer run in a separate process.  If you don’t want to go this route, see the original post below.

In XP we have a nifty little work-around to logging in as an admin without having to log the user off the desktop.  At the command line we can type:

C:\> runas /user:USERNAME@Domain “explorer /e, /separate”

Then it prompts us for our password and up pops a separate explorer shell running as our privileged account.  We can then proceed to do as we need.

In Windows 7 this doesn’t work 🙁  I did a little research and Microsoft now no longer allows us to run explorer as two separate users, simultaneously.  On the one hand this isn’t as much of a problem because Powershell supports UNC paths so we can get to wherever we need to go in the new shell.  I’ve just started reading “Learn Windows Powershell In a Month of Lunches” and I’m liking PS a lot already.  MS seems to be moving towards many of their apps working on top of Powershell (like the Exchange GUI) so it’s a good idea to learn.  You can right-click on Powershell and choose “Run as Administrator” to load it as yourself.  Unless you’re not comfortable with the command line (and you should be if you’re an administrator), I can’t see the need to use the explorer GUI anymore.  However, I wanted to see if I could figure out how to do it…

Let’s say you don’t want to learn Powershell or you have some reason for wanting the GUI (and I’ll set my devil’s advocacy aside for a moment).  I did figure out a way to do it shortly after my frustrating moment of reading about MS’s change with Explorer (I can’t complain too much though, it IS more secure), but not quite like XP.  MS stopped us from running Explorer as two simultaneous users.  All you have to do is kill the explorer process and then start it again as another user.  Since XP, we’ve had a clean way to do this without having to completely logoff the machine or close any other processes open on the PC.  Through this whole procedure, any running processes that were open as the user will stay open and running under their user context.  So here’s the step-by-step:

 

  1. As a precaution you can ask the user to save changes to anything they have open.  However, the process shouldn’t close anything except Explorer.
  2. Open a command prompt or powershell as the current user.  This is important!
    1. You can alternately open up Task Manager as the current user so long as they have the ability to do a “Run” (you may have this disabled in your environment for security reasons)
  3. Open up another command prompt with your admin privileges.
    1. You can either right-click on cmd or powershell and “Run as Administrator” or…
    2. From the users shell type:
      C:\> runas /user:USERNAME@Domain cmd.exe
  4. You should now have two shell windows open.  One under your user context and one under theirs.
  5. Click on the Start button.  Put your mouse over in “dead space” next to the shutdown button.  Hold CTRL + ALT + SHIFT and right-click in that dead space.
  6. You should have a context menu with “Exit Explorer” as an option.  Click it and you will see the desktop and taskbar disappear as explorer exits.
    1. If you opened Task Manager you’ll see that all other processes continue to run.
  7. Now, in the shell under your admin context, type:
    C:\> explorer
  8. Explorer will now open up and you’ll see your own desktop.  Go ahead and do whatever you need to do.  You should also close the shell window you have open as your context.  You don’t want to walk away and leave it open for the user to do what they want!
    1. You’ll also notice that all of the applications the user had left open are still open and running on the taskbar.  Again, you’ll also notice it in the Task Manager.
  9. CLOSE EVERY WINDOW YOU OPEN UNDER YOUR CONTEXT.  Just as the users running applications stayed open under their credentials, so will yours continue to stay open as you after you switch the desktop back to the user.
    1. This is also a good reason to learn Powershell.  You will only have to remember to close that one window and even if you did leave it open, chances may be good the user wouldn’t know how to use it.
  10. Now that we’re done doing our administrative tasks, lets get the desktop back to the user.
  11. With the shell still open under their context, perform the clean explorer shutdown in step 5.
    1. If you closed their shell, open one as you and do a runas but for their login and have them type in their password so it will launch.
  12. From their shell type:
    C:\> explorer
  13. They should now be back to their regular desktop with their same applications still running as them.
  14. Since I can’t stress this enough… Open up Task Manager to make sure there are no running processes under your user context!  Because they aren’t an admin, you will need to click the button “Show all users processes” and login as yourself to be able to see them if they still exist.

I only did minimal testing with this shell changing.  However, I didn’t notice any issues with the desktop or user context getting “messed up” because of the switching.  Microsoft intentionally made the CTRL + ALT + SHIFT method for a way of cleanly exiting and restarting explorer.  Desktop icons, background, folder permissions (I only checked one) were appropriate to whoever explorer was currently running as.  I strongly suggest you do some testing yourself, however.  If anything you’ll get more familiar with the process.

I like to give credit when I can, but the only thing I would give credit to someone else for is learning the XP command for running as another user.  It’s been one of my tools for so long I can’t remember, though :\  I did a quick Google search to find something familiar and this page is definitely one I’ve been on before:  http://blogs.msdn.com/b/aaron_margosis/archive/2004/07/07/175488.aspx


2 May 2012

Edit:

I’ve had to do this again.  So here is where to put the files on Ubuntu 12.04 with Citrix Receiver 13:  /opt/Citrix/ICAClient/keystore/cacerts

What I did was extract the roots.zip to that folder (which you have to do in the terminal using sudo….. sudo unzip “zip file” -d /opt/Citrix/ICAClient/keystore/cacerts)

Then, since the certs need to be in the cacerts dir and not a subdir, I did this from the terminal:  sudo cp /opt/Citrix/ICAClient/keystore/cacerts/VeriSign\ Root\ Certificates/Generation\ 5\ \(G5\)\ PCA/* /opt/Citrix/ICAClient/keystore/cacerts

And then I was able to launch!

Original Post:

For Receiver 12 on Ubuntu 11.10:

If you tried installing Citrix Receiver on Ubuntu 11.10 you may have run into a perpectual “SSL error 61”

There are various sites out there that tell you to to fix the issue you have to copy the cert to /user/lib/ICAClient/keystore/cacerts/  which may or may not exist on your box after installing.

I’ve found this to not work with with Ubuntu 11.10.  Instead, I had to copy them to the keystore in the actual installation directory of the app.  I just used the default install path of /home/MYUSER/ICAClient/.  It creates the directory /home/MYUSER/ICAClient/linuxx86/keystore/cacerts and that is where you have to dump the files.  Incase you’re having trouble finding the certs to download, they are here:  http://www.verisign.com/support/roots.html   The links for the various downloads begin after the form (which you can ignore).  The very first download link below the submit button is to download ALL root and intermediate certificates.

So basically, if you are having trouble getting it working on any distro, try looking for the cert folder in your installation directory.  The latest version, 12.1, I’m sure is the similar.  I believe it’s default installation path is /opt/ICAClient/linuxx86 but the last time I tried to download it, the file was corrupt or the server having issues and I haven’t tried again.


14 March 2012

So my mint-condition copy of Windows 98SE arrived today and after work I got it setup in VirtualBox.  Much easier than Windows 95 (and much easier than the way many folks on the net did it).  I googled it quickly to see what people ran into but figure screw it, why I don’t I just do things my usual way and find out for myself?  See my previous post about Win95 to see my versions/specs that I’m running this on.

Unlike it’s predecessor, Win98 can boot off the CD and doesn’t actually need the startup disk.  Once you create the HD (I chose VDI again) for it, be sure to go into Settings > System and disable hardware acceleration again like we had to for Win95 (UNCHECK “Enable VT-x/AMD-V”).  If you don’t do this, you’ll receive a “Fault outside of MS-DOS Extender” error.

Then when you boot, select your CD drive with Win98 and you’ll be brought to a screen asking to boot to the local HD or the CD.  Choose CD since you don’t have anything on the HD yet and it will start the dos-based setup.  It’s just a few [Enter]’s and then it’s asking you to reboot to begin the GUI-based install.

Then it’s just go through the GUI wizard and do as it asks.  When the file copying process finished I had to reboot.  When loading for the first time and before getting to the next stage of install (setup:  detecting pnp, setting date/time, etc) I got a blue screen.  I remembered seeing something somewhere about turning on ACPI so I closed down the VM and turned that on (Settings > System).  However, this significantly slows down response time so after I finished getting it all setup I turned this off again and it booted fine.

Once up, you dont get the internet setup Wizard like the Win95 install.  When you launch IE it tries to go through a wizard to detect your modem and wont do anything else.  You have to go into the control panel, open internet options, go to the connection tab, and click the setup button at the top to setup to use as a LAN.  I didn’t have to fill out my gateway but it was probably because my first attempt to get the internet working without a modem was to go into my network adapter properties and configure TCP/IP with my gateway (router) IP.

And that was it, super easy.  Didn’t have to create a boot iso or any kind of iso.  No special storage setup.  I suggest leaving it to boot to CD until you get to the desktop and setup is done.  Then you can go into Settings > Storage (for the VM) and remove the CD drive.


10 March 2012

Update 2-1-2021:  I’ve added a few caveats to the instructions below while needing to run through this process again with VirtualBox version 6.1.16

It’s been much longer between my posts than I’d like.  We had a re-org at work a little while back and now I’m up for another position that I’m waiting to hear on.  It’s like a desktop administrator position but more.

I have a bit of a nostalgia bug and I found my old copy of Windows 95 a while back.  I’ve been wanting to install it in a VM so I could play around with it again and remember old times.  I made an ISO from it, mounted it, and attempted an installation.  I forgot back then that CD’s weren’t bootable and I didn’t still have the boot disk.  I do, however, still have my old Win98 boot disk.  I think it has corrupted, however.  It wouldn’t matter tho, I don’t think, as I only have an external floppy drive and the software back then didn’t support USB!

So I looked on the net and found some boot disk images.  I also did a quick google search to see how complicated it was for other folks.  There sure are a lot of folks that had a lot of problems!  I found it to be farely simple, to be honest.  I did get a few tidbits of info that helped me along in my adventure to figure it out.  I’ll have several links at the end of the post.  But here’s how I did it:

I’m running VirtualBox 4.1.2 r73507 on Windows 7 Ultimate, 64-bit
I have Windows 95 “A” (although the boot disk I found will work for either, I believe)

Boot Disk and Installation CD

  1. If you don’t have the original boot floppy you’ll need to get a copy of the boot disk image from:  http://www.allbootdisks.com/
  2. Make an ISO of your Win95 CD and save it somewhere.  You can mount this directly in VirtualBox which is nice.  If you don’t want to do it that way, you can make another virtual drive and mount it in MagicDisc (another free app)
  3. An alternative is to create a single ISO that includes the boot disk and Win 95.  I’ve outlined that below, or you can skip to step 4.
    1. You can also burn both the boot disk and the Win 95 files to the same disc (but this as issues) to make one, bootable CD!
      1. To do this in ImgBurn launch the program and select “Write files/folders to Disk”
      2. On the window that comes up, the left space is where you add the folders and files (don’t forget both, they are separate icons) from the Win 95 CD.  The icons are have magnifying glasses over a sheet of paper and one over a folder.  I added the files and then each of the folders individually so that they will be at the root of the file structure.  Also add the program xcopy!
      1. Click on the “Advanced” tab on the left and then on “Bootable Disc” below that.
      1. Check the box “Make Image Bootable”
      1. Emulation Type:  Floppy Disk 1.44MB
      1. Boot Image:  add the .img file you downloaded from above.
  4. That should be it for your discs.  I highly recommend having two ISO’s and just mounting them in VB, but hopefully the steps above will help you if for some reason you can’t do that

VirtualBox Setup

  1. Started off by creating a new 5GB VDI Hard disk and making it Windows 95
    1. I configured mine to use 512MB of RAM
  2. BEFORE LAUNCHING THE NEW DISK you need to change some configuration.
    1. Right click on the new VDI in your list and go to Settings
    2. Select System on the left and you can configure your RAM size if you didn’t already.  Also change the Boot order so that the CD/DVD-ROM is first
    3. Click on the Acceleration tab and UNCHECK “Enable VT-x/AMD-V”
      1. If you don’t do this step, when you go to boot after installation of Win 95 you’ll hang at a black screen.
    4. Click on Storage on the left so we can add the ISO’s we’ll be using.
    5. Click the icon that has a plus sign over a single disk (not a disk stack) to add a CD/DVD Device
      1. Add the Bootable image FIRST so that it is the primary slave (which is what it will try to boot from)
        1. In newer versions of VBox this has changed. You must add a Floppy controller separate from the IDE controller (I82078 Floppy Drive) and mount the image to that
      2. Then add the Win 95 installation iso
    6. Click OK to save the settings
  3. Launch the new VDI!
  4. PAY ATTENTION to the initial boot screen.  It’s going to list two drives right above the A:\> prompt.
    1. The first drive letter is your Win 95 installation CD (Mine is set to R:\).
    2. The boot disc is automatically mounted to the A: drive.
  5. Since this is a brand new VDI there is no partitioned drive.  Win95 setup isn’t capable of creating one so you have to do that.
    1. Type format c: at the prompt and hit [enter].  Type Y for yes when it asks if you’re sure and hit [enter].  You can enter anything for the Volume label.
      1. If there is no C drive or only one drive listed instead of 2, you’ll need to run fdisk first.  From the A: prompt type FDisk, type Y to accept the large disk support, then just run through the next menus, all option 1.  Once it’s done, restart the machine (you’ll probably just have to power off then power it back on).  Then you’ll be able to do format c:
      2. You may need to  power off again and unmount the bootdisk .img file if you can’t get past the scandisk after running setup in step 7 eblow.  While going this FDisk route, I ran into an issue where scandisk kept complaining about the disk being compressed.  After many partition deletes, reformats, and head banging, I wondered if it was the floppy drive it was actually scanning.  Turns out it was because after unmounting the .img file and then turning it on again, I was able to run setup from C:\WIN95\
        1. on my last format c: I did use the /s command, too, but I’m not sure that was necessary.
  6. The Win95 setup doesn’t mount your CD drive after you reboot , thus the continued setup for Windows can’t complete because it cant find the Win95 CD.  You’ll get a bunch of dll errors.  The OS will still boot but it’s a lot of errors.  To fix this we need to copy the Win95 CD to the C drive so we can access it later.
    1. From the A:\> prompt type xcopy R:\ C:\WIN95\ /S
      1. Remember to substitute R: for the drive letter that yours is.
  7. Now switch to your C: drive to run the setup
    1. Type C: and hit [enter]
    2. Type cd win95 and hit [enter]
    3. Type setup and hit [enter].  It will tell you it has to do a scan before it can install, hit [enter] to proceed.
  8. You should now be in the setup wizard for Win 95.  I’ll trust you can follow the prompts from here.
  9. When it prompts you to restart after install is a good time to click on “Devices” and unmount your bootable iso.  When I restarted after that I got a boot failure, but I just used “Reset” in the Machine menu to reset the box and then it was fine.
  10. It should then proceed with the usual setup and ask you a bit of input.
  11. After another reboot you should be all set to use Windows 95!

Getting on the Internet

I wasn’t sure if this would work but I was easily able to get on the internet.  The bad part is most pages are using code that Internet Explorer 4 can’t render.  However, if the site still uses just basic HTML you should be able to render it fine.

  1. Please note you’ll have wanted to install the virtual networking driver when you initially installed VirtualBox on your machine.
  2. Launch the “The Internet” icon
  3. Select to connect via your LAN
  4. Use DHCP
  5. Your DNS server will be your router IP
  6. Your Gateway will be your router IP
  7. Save it and reboot like it says

One “old school html” page you can load to try it out is www.bootdisk.com

And that’s it!

I did a lot of trial and error trying to figure out the best way to make the ISO’s and mount.  It wasn’t until I got the xcopy idea that it all became beautifully simple.  But if I had looked in the first place, I would have seen xcopy was part of the downloaded boot image all along :\  It was fun though!

Here are the links where I got a few tidbits of info to help me along:

http://www.sevenforums.com/virtualization/10121-installing-windows-95-virtualbox-5.html   (this is really the only one that helped me)
http://ubuntuforums.org/showthread.php?t=533611   (sort of, it pointed me in a different direction which made me realize I needed to pursue a different path)
http://www.youtube.com/watch?v=Awo948eU_eE   (I tried installing DOS 7.1 first but didn’t want to mess around with mounting my drive)


Links

RSS 2.0 Feed

Support

Brave Rewards
This site supports Brave Rewards. Please consider tipping or adding it to your monthly contributions if you find anything helpful!

For other ways: Support

Support this blog! If you have found it helpfu you can send me crypto. Any amount is appreciated!
ETH: 0xBEaF72807Cb5f4a8CCE23A5E7949041f62e8F8f0 | BTC: 3HTK5VJWr3vnftxbrcWAszLkRTrx9s5KzZ | SHIB: 0xdb209f96dD1BdcC12f03FdDfFAD0602276fb29BE
Brave Users you can send me BAT using the browser.