Solved

# open folder in powershell

Posted on 2010-09-01
Medium Priority
1,454 Views
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
Question by:mhamer
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2

LVL 42

Expert Comment

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

LVL 42

Accepted Solution

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

Author Comment

ID: 33576597
Great works perfectly thank you

what would be the vb equivilant?  just out of interest?  you get the points anyway
0

LVL 42

Expert Comment

ID: 33576703
in vb script:

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

0

Author Comment

ID: 33577013
unterminated string constant  when i use that
0

LVL 42

Expert Comment

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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…
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…
###### Suggested Courses
Course of the Month12 days, 17 hours left to enroll