简体   繁体   中英

Need help in Powershell for Python programming

So, I bought this book called "Learn Python the Hard Way" and in the learning progress as it is my first programming language.

The problem I'm facing now is I couldn't create a directory in Powershell for Windows 7. I followed exactly like what the book said " mkdir mystuff " and I got the following error.

All I want is to make the directory becomes like this

C:\Documents and Settings\User\mystuff 

How do I solve this ? Your help is greatly appreciated.

Everything works fine in WindowsXP but not Windows 7.

    PS C:\Windows\System32\WindowsPowerShell\v1.0> mkdir mystuff
    New-Item : Access to the path 'mystuff' is denied.
   At line:38 char:24
    +         $scriptCmd = {& <<<<  $wrappedCmd -Type Directory @PSBoundParameters
    }
         + CategoryInfo          : PermissionDenied: (C:\Windows\Syst...ll\v1.0\mys
      tuff:String) [New-Item], UnauthorizedAccessException
     + FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft
   .PowerShell.Commands.NewItemCommand

Windows is preventing you from adding a directory to the System32 folder. You don't have permission to do so by default, because really you shouldn't do that.

Instead try changing directory to somewhere more reasonable and making the directory there. %UserProfile% is an alias for your home directory .

cd %UserProfile%
mkdir mystuff

The reason this works in XP, by the way, is that XP isn't very strict about security or permissions. Which is wrong. : )

Based on the prompt you're trying to create a folder in the PowerShell directory path and you don't have the appropriate permissions to do so. Try this instead:

mkdir $env:USERPROFILE\mystuff

If you wanted to create the directory C:\\Documents and Settings\\User\\mystuff , try to be explicit about it:

cd "C:\Documents and Settings\User\"
mkdir mystuff

Have fun learning Python. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM