I have come across a small issue
I have a rather simple script that runs as a logon script which renames the Home Drive set by AD, script below
This works perfectly at logon if the user is connected to the Domain at the time of logon. If a user logs on off the network (I,e. working at home offline), when this script is run manually the mapped drive does not rename like it does at a logon where the computer is connected to the system.
Any ideas why it wouldn't work with a manual run, the users are local admins on the computers they are trying to run this on.
On Error Resume Next
Dim objNetwork, strUserName, objApp
Set objNetwork = CreateObject("Wscript.Network")
Set objApp = CreateObject("Shell.Application")
strUsername = objNetwork.UserName
MapDrive "W:", "Home Drive (" & UCase(strUserName) & ")"
Wscript.Quit
'RENAME MAP NETWORK DRIVE FOR MEMBERS OF CERTAIN GROUP
Sub MapDrive (strLetter, strDescription)
On Error Resume Next
Err.Clear
objApp.NameSpace(strLetter & "\").Self.Name = strDescription
On Error Goto 0
End Sub
Rename Mapped Drive
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- SAPIEN Support Forums
- Posts: 945
- Last visit: Thu Oct 22, 2015 1:10 pm
Rename Mapped Drive
This is an automated post. A real person will respond soon.
Thank you for posting, devereux0110.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
Anticipate follow-up questions!
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, devereux0110.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
- - Scripting question? For questions about Windows PowerShell or other scripting languages, use Scripting Answers.
- Software question? For questions about PowerShell Studio, PrimalScript, or other SAPIEN products, use Product Support Forums for Registered Customers.
- Trial question? For questions about trial versions of any SAPIEN product, use Trial Software Questions.
Anticipate follow-up questions!
Did you remember to include the following?
- 1. Product, version and build
2. 32 or 64 bit product
3. Operating system, e.g. Windows 7 64 bit.
4. Attach a screenshot, if applicable
5. Attach logs, crash reports, etc., in a ZIP file
*** Make sure you do not post any licensing information ***
- devereux0110
- Posts: 38
- Last visit: Mon Oct 02, 2017 7:11 am
Re: Rename Mapped Drive
I think you missed a bit of what i said.jvierra wrote:Logon scripts cannot be run when not connected to the domain.
It works as a logon script no problem.
The question was, when running the script manually after a logon as taken place offsite, it doesn't rename the mapped drive as expected
I know a logon script wont work when not on the network but a script should work when run manually.
Is there any suggestions on why the script wouldn't work if run manually
Re: Rename Mapped Drive
Without al of the extra lines this is the whole functional script. Run it and see what errors you are getting then address the errors.
VBScript Code
Double-click the code block to select all.Set objNetwork = CreateObject("Wscript.Network") Set objApp = CreateObject("Shell.Application") objApp.NameSpace("W:\").Self.Name = "Home Drive (" & objNetwork.UserName & ")"
- devereux0110
- Posts: 38
- Last visit: Mon Oct 02, 2017 7:11 am
Re: Rename Mapped Drive
The results are the same, works when used as logon script but not running manually.jvierra wrote:Without al of the extra lines this is the whole functional script. Run it and see what errors you are getting then address the errors.
VBScript Code
Double-click the code block to select all.Set objNetwork = CreateObject("Wscript.Network") Set objApp = CreateObject("Shell.Application") objApp.NameSpace("W:\").Self.Name = "Home Drive (" & objNetwork.UserName & ")"
however a bit more information we realised to go with this, it only doesn't rename the drive if the drive as been offline and then comes online again.
No error messages are displayed, it run and then closes as expected, the drive just doesn't rename as expected.
Re: Rename Mapped Drive
For that to work the drive must be physically attached to the computer and not be a network drive. You cannot authenticate to a network share when not in the domain.
If it is a physically attached drive then you likely have other issues that have nothing to do with scripting.
Consider using the "label" command to verify what you are doing.
label /?
If it is a physically attached drive then you likely have other issues that have nothing to do with scripting.
Consider using the "label" command to verify what you are doing.
label /?
- devereux0110
- Posts: 38
- Last visit: Mon Oct 02, 2017 7:11 am
Re: Rename Mapped Drive
OK, a user logs on when at home and files are available offline.jvierra wrote:For that to work the drive must be physically attached to the computer and not be a network drive. You cannot authenticate to a network share when not in the domain.
If it is a physically attached drive then you likely have other issues that have nothing to do with scripting.
Consider using the "label" command to verify what you are doing.
label /?
The user then closes the lid on their laptop and puts the laptop to sleep.
When the user comes in school and wakes the laptop in a logged on states and connects to the network, the Offline Drive then goes back online and connects normally but has not been renamed.
Running the script at this time does not rename the drive.
A fresh logon where the script runs as a logon script, the same drive which is already on line renames with no issues
Re: Rename Mapped Drive
I thought the issue only happened when the user was not connected to the network.
Why are you renaming a drive that is not connected?
I am afraid that this is a hardware issue and not a scripting issue. It may also be a result of trying to use the shell to rename a disconnected drive. The shell is not intended to be used this way.
You can use the net mapping commands to label a mapped device. It will usually be more reliable.
Why are you renaming a drive that is not connected?
I am afraid that this is a hardware issue and not a scripting issue. It may also be a result of trying to use the shell to rename a disconnected drive. The shell is not intended to be used this way.
You can use the net mapping commands to label a mapped device. It will usually be more reliable.