Hey everyone,
I’m trying to create a task to map network drives. So far it looks like this:
// Prompt to query drive letter
action parameter query “unidade” with description “Drive letter:” and with default value " "
// Prompt to query foldername
action parameter query “pasta” with description “Sharename:” and with default value " "
delete __createfile
delete run.bat
createfile until end @ECHO OFF
waithidden cmd /C net.exe use {parameter “unidade” as string}: \\network\{parameter “pasta” as string} /persistent:yes end
I think, something that you need to take into consideration is that when you run some of this stuff. it normally runs as System and then the scripts dont work as Im assuming you want the drive to be seeing by the end user that us currently logged in.
now, if this the above works, yo can always create the .bat and use the wizard to upload it for you. it will enter all needed commands to execute the .bat
as per Network mapping to all profiles, I think you are better off to resort to AD or group policy
Indeed, it normally runs as System that’s why I’ve tried using the runas=currentuser line, although I’ve never used it this way before and I’m not sure how this effective works.
We are using AD mapping but, for some don’t identified reason, a few computers are not mapping automatically and our support center has to do it manually through remote access.
The idea in here is to map this networks using the current logged on user credentials without bothering the user.
As I said, it is an idea. I ain’t sure if it is realy possible.
But using net share, as far as I know, is for sharing a folder to make it available to another remote user.
What I’m trying to accomplish is to map a network drive, to assign a drive letter to a specific shared folder of a server on a computer.
@baynes74
Thanks for your help but the problem is that with your command lines Bigfix execute as system and not as current user, so the task stops waiting for the login and password to map the drive despite the user is logged and have the correct permissions.
It worked using Software Distribution where I could upload a bat file and set the task to execute as current user. However, the bat file contained the full command line:
net use X: \network\foldername /persistent:yes
The intention is to allow the operator to set the drive letter and the foldername:
net use {parameter “driveletter” as string}: \\network\{parameter “foldername” as string} /persistent:yes
Actually the parameter replacement works fine. The command line works fine in a bat file through Software Distribution but this way I can set a parameter to the drive letter and folder name.
The idea is allow the operator to set the drive letter (I already have a property to show which letter is free) and the specific server folder to be mapped. This will be used when, for some reason, the correctly server folder isn’t automatically mapped to a specific user through AD policy. Despite we are investigating these problems, users can’t wait to access these files to work.
for the current user…
action parameter query “New Drive” with description “Enter the Drive Letter with a : and fqdn path that you wish to map” with default value “Z: \servername\share”
prefetch RunAsCurrentUser.exe sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528 http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe
utility __Download\RunAsCurrentUser.exe
waithidden __Download\RunAsCurrentUser.exe --w --q cmd.exe /C NET USE {(parameter “New Drive” of action)} /persistent:yes
to Delete…
action parameter query “Mapped Drive” with description “Enter the Drive Letter with a : that you wish to unmap” with default value “Z:”
prefetch RunAsCurrentUser.exe sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528 http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe
utility __Download\RunAsCurrentUser.exe
waithidden __Download\RunAsCurrentUser.exe --w --q cmd.exe /C NET USE {(parameter “Mapped Drive” of action)} /DELETE
However, somehow I manage to make it work without the need of downloading the RunAsCurrentUSer file.
Below is the code that worked as well as yours:
action parameter query “letter” with description “Enter the drive letter:” and with default value "Z"
action parameter query “folder” with description “Enter the folder name:” and with default value " "
@ECHO OFF
echo Command: “cmd /C net.exe use {parameter “letter”}: \\server\{parameter “folder”} /persistent:yes”>> "{parameter “logFolder”}{parameter “logFile”}"
set errorlevel=
“cmd /C net.exe use {parameter “letter”}: \\smb.mppr\{parameter “folder”} /persistent:yes”>> “{parameter “logFolder”}{parameter “logFile”}” 2>&1
set SWDExitCode=%errorlevel%
rem //**End Command Marker
exit %SWDExitCode% end