GVKun编程网logo

C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败

16

在本文中,我们将带你了解C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败在这

在本文中,我们将带你了解C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败在这篇文章中,同时我们还将给您一些技巧,以帮助您实现更有效的6: Commits And The Working Directory(Git Remotes )、C# CreateDirectory 找不到部分、c# – Directory.GetCurrentDirectory()根据命令行参数返回不同的结果、c# – Environment.CurrentDirectory vs System.IO.Directory.GetCurrentDirectory

本文目录一览:

C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败

C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败

使用C#WMI我在另一台计算机上启动一个exe文件,此exe文件使用C# Process类启动另一个exe文件。 最后一个exe尝试使用networkingpath(aka \\comp1d$dir )调用Directory.CreateDirectory 。 Directory.CreateDirectory引发这个exception:

Access to the path ''\\blahblahblah'' is denied. at System.IO.__Error.WinIOError(Int32 errorCode,String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath,String path,DirectorySecurity dirsecurity) at System.IO.Directory.CreateDirectory(String path,DirectorySecurity directorySecurity)

如果我直接在计算机上的控制台上运行第三个exe它存在这个exception不会引发,一切工作正常。

正在创build目录的文件夹的安全设置具有“所有人”给予完全权限。

我该如何解决这个问题?

我如何使用rmdir删除Windows目录?

无法删除CentOS上的用户目录

如何使用C#在远程Windows计算机上创build共享文件夹?

Rsync没有正确设置Windows文件夹的权限

另外请注意,通过WMI启动应用程序时,还有第三层权限。 例如,如果你调用一个现有的WMI对象的方法,它可能不会委托调用者的权限,甚至主持人的权利,但将有一个空主体。 这可能发生在你身上。

转到“计算机管理”,然后在“服务和应用程序”下,右键单击“WMI控制”节点并选择“属性”。 转到安全选项卡,然后导航到正确的WMI名称空间(很可能是root CIMV2),并确保您使用的用户也具有相应的权限。

正如Aaron所说,windows共享安全有两个组成部分,第一个是共享本身的安全性。 第二个是该共享中文件和文件夹的安全性。

两者都必须允许创建目录访问才能工作。

您还应该知道,EVERYONE组包括域计算机帐户,内置系统帐户,域用户,来宾和已验证的用户。

这意味着你要做的第一件事就是看看实际运行的是哪个用户。 如果它在计算机帐户下运行,并且它不是域的一部分,那么您将需要授予该计算机帐户访问共享和文件系统的权限。

看到这个线程的一些关于权限的建议。

http://www.eggheadcafe.com/community/aspnet/2/10058550/how-to-create-a-folder-in.aspx

总结

以上是小编为你收集整理的C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

6: Commits And The Working Directory(Git Remotes )

6: Commits And The Working Directory(Git Remotes )

Before we dive more into commits, let''s take a closer look at the working directory and how it interacts with commits. As you may recall from the previous mission, the git commit workflow has three main components:

  • The working directory
  • The staging area
  • Commits

The working directory is the folder that you''re version controlling with git, and the contents of the working directory are what you see when you list the contents of the folder with ls. In our case, /home/dq/chatbot is the working directory. You can edit the working directory by changing or adding files.

So let''s say our working directory looks like this:

WorkingDirectoryStagingAreaCommitsREADME.mdThisisaREADME!

In the above example, we have one file, calledREADME.md, in the working directory. There are no files in the staging area, and no commits.

When we run git add, git adds the changes between the most recent commit and our working directory into the staging area, like this:

WorkingDirectoryStagingAreaCommitsREADME.mdREADME.mdThisisThisisaREADME!aREADME!

When we run git commit, we create a commit that contains all of the changes in the staging area. The commit also has a unique commit hash, so we can refer to it later. Note how making a commit removes all changes from the staging area:

WorkingDirectoryStagingAreaCommits53dREADME.mdREADME.mdThisisThisisaREADME!aREADME!

We now have a commit, with the hash 53d, that is a snapshot of the working directory at the moment, when it contains a file calledREADME.md, with the contents This is a README!.

We can then add a file to the working directory, and edit README.md. This will only affect the working directory, where we''re making changes:

WorkingDirectoryStagingAreaCommits53dREADME.mdbot.pyREADME.mdThisisn''tprint(1)ThisisaREADME!aREADME!

We can then use git add to stage our changes:

WorkingDirectoryStagingAreaCommits53dREADME.mdbot.pyREADME.mdbot.pyREADME.mdThisisn''tprint(1)Thisisn''tprint(1)ThisisaREADME!aREADME!aREADME!

In this case, git adds both the new and the changed file into the staging area. We can then commit the change:

WorkingDirectoryStagingAreaCommits53dREADME.mdbot.pyREADME.mdThisisn''tprint(1)ThisisaREADME!aREADME!12cREADME.mdbot.pyThisisn''tprint(1)aREADME!

We now have two commits, each storing a snapshot of our working directory at a different point in time. In the next screen, we''ll cover how to switch between commits to change the files in our working directory.

You can see the difference between two commits by using git diff. Just pass the two commit hashes as arguments to git diff. If you want to save yourself typing time, you can also use the first few characters of the commit hash (usually 4 is enough) to uniquely identify the commit. The order in which you pass the two hashes to git diff influences whether changes appear as deletions or additions.

You''ll need to use q to exit git diff when you''re done.

Instructions

  • Use git diff to find the difference between your two commits

 

/home/dq/chatbot$ cd /home/dq/chatbot                                           

/home/dq/chatbot$ HASH=`git rev-parse HEAD~1`                                   

/home/dq/chatbot$ git --no-pager diff $HASH2 $HASH                              

diff --git a/README.md b/README.md                                              

index f4871de..c2efe6e 100755                                                   

--- a/README.md                                                                 

+++ b/README.md                                                                 

@@ -1,3 +1,3 @@                                                                 

 README                                                                         

                                                                                

-This is a README file.  It''s typical for Github projects to have a README.  A R

EADME gives information about what the project is about, and usually how to inst

all and use it.

\ No newline at end of file                                                     

+This is a README file.  It''s typical for Github projects to have a README.  A R

EADME gives information about what the project is about, and usually how to inst

all and use it.This project needs no installation                               

\ No newline at end of file                                                     

/home/dq/chatbot$                                                               

 

Copy: Ctrl+a, Ctrl+c

 

C# CreateDirectory 找不到部分

C# CreateDirectory 找不到部分

没关系,我是个白痴,我是通过调试来做到这一点的,所以它正在我的本地机器上寻找文件。 GG

c# – Directory.GetCurrentDirectory()根据命令行参数返回不同的结果

c# – Directory.GetCurrentDirectory()根据命令行参数返回不同的结果

我希望有人可以解释为什么Directory.GetCurrentDirectory()根据我将命令行参数传递给应用程序的方式返回不同的结果(使用args运行vs在app.exe上拖动文件夹)

要直接进入它,请考虑以下代码:

public class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("The current directory is {0}",Directory.GetCurrentDirectory());

        if(args != null && args.Any())
            Console.WriteLine("Command line arguments are {0}",String.Join(",",args));

        Console.ReadLine();
    }
}

如果使用命令提示符构建并运行它,如下所示,则输出就是您所期望的.它将输出应用程序所在的当前目录.

C:\Projects\ArgumentTest\ApplicationA\bin\Debug\ApplicationA.exe C:\mydirectory
The current directory is C:\Projects\ArgumentTest\ApplicationA\bin\Debug\
Command line arguments are C:\mydirectory

如果通过在应用程序上拖动文件或文件夹来构建和运行此程序,则会得到不同的结果.而不是返回预期的结果而不是Directory.GetCurrentDirectory()返回您在应用程序上拖动的第一个文件的路径.

我现在有一个解决这个问题的方法,但我很想知道为什么会这样.

其他信息:

> .NET 4.5
> Windows 2012R2(虚拟机)
>机器的完全管理员权限

希望有人可以提供一些见解.

解决方法

我认为这里的问题是你的期望.特别是这一点:

It will output the current directory the application resides in.

这不是我对GetCurrentDirectory()的期望.当前目录是调用上下文的一个功能,而不是应用程序.如果我通过完整或相对路径(而不仅仅是foo.exe)运行可执行文件,我希望GetCurrentDirectory()返回我所在的目录 – 而不是应用程序所在的目录.在拖动文件的情况下它:坦率地说,GetCurrentDirectory()在很大程度上是未定义的,但第一个文件的目录并不合理.

c# – Environment.CurrentDirectory vs System.IO.Directory.GetCurrentDirectory

c# – Environment.CurrentDirectory vs System.IO.Directory.GetCurrentDirectory

我正在写一个.Net WinForms并且不断在DEBUG和RELEASE配置之间切换,并且我需要一些配置才能到达的文件.

我想要做的是将文件放在BIN文件夹中的公共目录中,这样看起来像这样:

MyProject/Bin/CommonFiles
MyProject/Bin/Debug
MyProject/Bin/Release

我正在考虑使用以下内容访问文件:

System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory).FullName

我的问题是,如果这是危险的,因为从我读过的内容,System.IO.Directory.GetCurrentDirectory可能会因用户在打开的文件对话框中选择一个新的当前目录而改变.

我是否应该使用以下内容:

System.IO.Directory.GetParent(Environment.CurrentDirectory).FullName

或者有一个更好的方式来到/ Bin文件夹,所以我可以从那里或一个普遍接受的方式/位置移动存储程序通常需要达到的文件和更容易引用的方式(可能是工作的东西与任何类型的应用程序,而不仅仅是WinForms)?

解决方法

您可以使用System.Reflection.Assembly.GetExecutingAssembly()获取应用程序的.exe位置.
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string exeDir = System.IO.Path.GetDirectoryName(exePath);
DirectoryInfo binDir = System.IO.Directory.GetParent(exeDir);

今天关于C#WMI在远程PC上运行一个exe,然后在同一台PC上运行另一个exe,然后在networkingpath上调用Directory.CreateDirectory,并失败的讲解已经结束,谢谢您的阅读,如果想了解更多关于6: Commits And The Working Directory(Git Remotes )、C# CreateDirectory 找不到部分、c# – Directory.GetCurrentDirectory()根据命令行参数返回不同的结果、c# – Environment.CurrentDirectory vs System.IO.Directory.GetCurrentDirectory的相关知识,请在本站搜索。

本文标签: