1

I'm trying to automate a process to the simplest way possible for non technical lab students. This is my first time doing longer scripts so bear with me.

I need the drive to:

  1. Check that the user is in an elevated terminal
  2. Print a short message
  3. Run 3 windows command scripts in sequence
  4. report time it took to complete the entire set of tasks

I've messed around in PowerShell more than anything else. So I would be most comfortable doing in that.

Can anyone point me towards any other resources (github, other SE articles etc.) that will help? I'm very willing to read and I have more than the average amount of patience.

2
  • 2
    Windows won't auto-run anything from a USB stick anymore, as it's considered highly insecure. Beyond that, we're not a script writing service, but will help with specific problems while scripting. So, what have you got so far, and where exactly are you getting stuck? Jun 10, 2014 at 20:47
  • @thelowend Just to make absolutely sure, you the script to run from the students usb?
    – EliadTech
    Jun 10, 2014 at 22:06

1 Answer 1

0

The Microsoft recommended way is to use the Windows Management Interface (WMI).

You can register an event in WMI that will periodically check to see if a USB change has occured and you can query that from PowerShell.

There was a Scripting Guy article on this in 2010. I haven't tried this myself though and I don't want to point you in the wrong direction so I'm not going to try to reproduce a summary here I'm afraid.

On the other hand, if you are open to alternative approaches, there are tools that do monitor for USB disk changes and can take actions accordingly. The backup tool Syncback for example can do this though I'm afraid I'm not currently certain which version you would need & only one of them is free. I use SyncbackSE and that certainly does detect disk insertions and will also check for specific disk identifiers.

1
  • Why go and check WMI events periodically, when you can just attach a script to the appropriate event (in the event viewer)? I think it'll be more efficient.
    – EliadTech
    Jun 10, 2014 at 22:01

Not the answer you're looking for? Browse other questions tagged .