Hi,

I am trying to get list of mapped drives and searched - so far what I've found is not producing the txt file, I cannot get it to work. I have a CIR ShellCommandTextReturn (cmd.exe /c type C:\temp\mapped.txt) and its not returning any result. What am I missing?  I am on v5.4.76847.

Tahnk you, 

Answer Summary:
Cancel
2 Comments   [ + ] Show Comments

Comments

  • how are you creating the mapped.txt file?
  • This is how I was doing it as a CIR ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt) but dugullett's comment makes sense this is running as a system and not producing any results.
Please log in to comment

Community Chosen Answer

4

I think you will just want to put your command in there directly in lieu of c:\temp\mapped.txt.

For ex:

ShellCommandTextReturn (cmd.exe /c type C:\temp\mapped.txt) - See more at: http://www.itninja.com/question/list-mapped-drives#sthash.EYE0s6oP.dpuf
 ShellCommandTextReturn (cmd.exe /c type C:\temp\mapped.txt) - See more at: http://www.itninja.com/question/list-mapped-drives#sthash.EYE0s6oP.dpuf
 ShellCommandTextReturn (cmd.exe /c type C:\temp\mapped.txt) - See more at: http://www.itninja.com/question/list-mapped-drives#sthash.EYE0s6oP.dpuf

ShellCommandTextReturn(cmd /c net use)

I use the above example for a couple of other commands and it works...

It will spit the output in your Custom Inventory Fields section listed in the computer inventory.

cmd.exe /c type C:\temp\mapped.txt
cmd.exe /c type C:\temp\mapped.txt
cmd.exe /c type C:\temp\mapped.txt
cmd.exe /c type C:\temp\mapped.txt
Answered 11/04/2013 by: jegolf
Red Belt

  • This is the same command I would use.
  • Jegolf- thanks for the quick reply. I tried the command ShellCommandTextReturn(cmd /c net use) and it returned nothing.

    1) CIR - Mapped Drives: New connections will be remembered.

    There are no entries in the list.

    [string]

    Thanks,
    • I don't believe that will work because it's running as SYSTEM. It looks like you may have a space in your original command line in between the ShellCommandTextReturn and the first (. You need to remove that to read the .txt file.
      • That was just a typo but if I put it in this way ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt) I get nothing.
      • Do you have the correct OSs selected?
      • I am getting the same error as OP. This is my syntax ShellCommandTextReturn(cmd /c net use) I am on V5.5
  • Apologies for the lead in the wrong direction. You may need to look at running a script and not a custom inventory rule so you can run it under the current user's context. A quick Google finds many examples to try or someone here may have one in the bag already...
Please log in to comment

Answers

2

dugullett has given you the reason it is not working. Any code running in SYSTEM context has NO access to any network resources so will not be able to see any mapped drives, as mapped drives exist in USER context.  Any code that seeks to establish drive mapping for a specific user needs to run in the context of that user. Perhaps if you explain what you are trying to achieve, a more viable solution might be proposed

Answered 11/06/2013 by: EdT
Red Belt

  • It makes sense. What I am trying to do is: I found out from some of our junior admins that they have been mapping drives manually and need to push out login script. But before I do that I would like to to know who is mapped to what so I can account for that and maybe remap the drive for them. I just need to know who is mapped to what network drive. Is there a way I can do this as a script and run it as under current user?
Please log in to comment
0

try net use C:\temp\drives.txt

 

Answered 11/05/2013 by: llawson
White Belt

  • This would still be the same issue and will be running under system and not user profile.
Please log in to comment
0

Any other suggestion? I need to figure a way to do this thing.

Answered 11/06/2013 by: bozadmin
Second Degree Green Belt

  • Is the .txt file showing results? Is Kace just not inventorying it?
    • its not creating the txt file and after doing agent debug seems like there is sytax error.

      [Wed Nov 06 16:38:01 2013] [CDeployController::ExecuteCustomInventoryRule] issuing rule [ShellCommandTextReturn(cmd.exe /c type C:\temp\mapped.txt);]
      [Wed Nov 06 16:38:01 2013] haveTokenLsaPriv returning: 1
      [Wed Nov 06 16:38:01 2013] KLaunchProcess: Call CreateProcess to launch 'KLaunch.exe . -wait -hide -stdout "C:\Windows\TEMP\dklA0F3.tmp" cmd.exe /c type C:\temp\mapped.txt':
      [Wed Nov 06 16:38:01 2013] KLaunchProcess: Wait for process to complete
      [Wed Nov 06 16:38:03 2013] KLaunchProcess: process completed status=1
      [Wed Nov 06 16:38:03 2013] [CDeployController::ExecuteCustomInventoryRule] statement result: "", FALSE
      [Wed Nov 06 16:38:03 2013] KDeploy finished processing 7 custominventory rules, sending response
      • Take a look at John's post on this. This script will run, and create a .txt file at c:\windows\KBOX\local_and_network_drives.txt. You then use your custom inventory rule to read that .txt file.

        http://www.itninja.com/question/extending-the-computer-inventory-to-support-user-profile-specific-other-non-inventoried-data
Please log in to comment
0

Thank you all for all the help and support you provide.

With the Help of Support I was able to get it working.

We ran it as Online Shell Script with Net use > "C:\Windows\Temp\mapped.txt"

Then use CIR ShellCommandTextReturn(cmd /c type "C:\Windows\Temp\mapped.txt")

To get it into Inventory.

Thank you,

Answered 11/07/2013 by: bozadmin
Second Degree Green Belt

Please log in to comment
Answer this question or Comment on this question for clarity