Solved

open folder in powershell

Posted on 2010-09-01
6
1,423 Views
Last Modified: 2012-06-22
hi, id like a powershell script to open a location

eg

when run the folder c:\data\test\%hostname%\tools    opens  much like if there was a shortcut to it


power shell preffered VB ok
0
Comment
Question by:mhamer
  • 4
  • 2
6 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33576449
use Invoke-item:invoke-item c:\data\test\%hostname%\tools
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33576477
to get %hostname% (envirnemtn variable) use the following:$hostname = $Env:hostnameinvoke-item c:\data\test\%hostname%\tools
0
 

Author Comment

by:mhamer
ID: 33576597
Great works perfectly thank you

what would be the vb equivilant?  just out of interest?  you get the points anyway
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 42

Expert Comment

by:sedgwick
ID: 33576703
in vb script:


Set objShell = CreateObject("WScript.Shell")

hostname = objShell.ExpandEnvironmentStrings("%hostname%")

objShell.Run "explorer c:\data\test\" & hostname & "\tools

Open in new window

0
 

Author Comment

by:mhamer
ID: 33577013
unterminated string constant  when i use that
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33577119
i forgot the " in line 3:

Set objShell = CreateObject("WScript.Shell")
hostname = objShell.ExpandEnvironmentStrings("%hostname%")
objShell.Run "explorer c:\data\test\" & hostname & "\tools"
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

18 Experts available now in Live!

Get 1:1 Help Now