Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#1
Post
by SIMMS7400 » 07 Sep 2017 06:41
Hi Folks -
I'm running into an issue where when I try to map a SharePoint URL to a drive letter using net use via batch script, I'm getting the following error:
Code: Select all
System error 1244 has occurred.
The operation being requested was not performed because the user has not been authenticated.
This happens when I supply the /USER: switch. However, it I use net use without, and I'm promoted to enter username and password, it works fine.
Does anyone have any ideas why?
Thanks!
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 07 Sep 2017 07:20
Making assumptions here.
1) Since you did not show any code I am going to assume you are using the NET USE command correctly.
2) I don't have share point to test with, but I would assume that if you are supplying the /USER option you will also have to supply the password with the NET USE command.
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#3
Post
by SIMMS7400 » 07 Sep 2017 10:04
Hi Squash -
I can confirm i'm using NET USE correctly as well as supplying the password to /USER:
Code: Select all
SET "CREDS=MPI\DonaldTrump MAGA"
SET "HORIZON_URL_STG=https://horizon.tttt.com/sites/rdfinance/TM1/DATA/Ascend_Headcount/Ascend_Headcount_Staging"
FOR %%D IN ( b d e f g h i j k l m n o p q r s t u v w x y z ) DO (
IF NOT EXIST %%D:\ (
SET "MD=%%D"
NET USE !MD!: "%HORIZON_URL_STG%" /USER:%CREDS%
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 07 Sep 2017 10:08
I don't see Delayed Expansion Enabled nor is there any need to use delayed expansion. Just use the FOR variable with the NET USE command.
-
Compo
- Posts: 600
- Joined: 21 Mar 2014 08:50
#5
Post
by Compo » 07 Sep 2017 10:40
Why use a devicename? does using NET USE * not map the next unused drive letter anyway?
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#6
Post
by SIMMS7400 » 07 Sep 2017 10:43
Hi Gents -
Yes, delayed expansion was at the top of my script - I cut it down to post here but forgot that piece.
Compo - yes however I need to preserve tat drive letter so I can delete that specific drive upon script exit.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#7
Post
by Squashman » 07 Sep 2017 11:08
Just from reading a few articles online it looks like you need to do some upfront settings in Internet Explorer to make it a trusted site and have it remember the credentials.
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#8
Post
by ShadowThief » 08 Sep 2017 11:30
Can you pushd to the folder instead?
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#9
Post
by SIMMS7400 » 08 Sep 2017 13:01
Hi Folks -
Shadow - I'm going to try that now.
Edit : 303pm - PUSHD doesn't seem like it works with URLs
Also and update : Sometimes the mapping works, other times it does not. It's really frustrating and I cant identify a constant to help me figure out why sometimes it works while other times it doesn't.
I'll report back.
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#10
Post
by SIMMS7400 » 08 Sep 2017 16:50
Whats interesting is that if I use the net use command without the /user switch so I can provide my username and password manually, the second piece of the mapping script will map fine, automatically with the /user switch...
Code: Select all
FOR %%D IN ( b d e f g h i j k l m n o p q r s t u v w x y z ) DO (
IF NOT EXIST %%D:\ (
SET "MD=%%D"
NET USE !MD!: "%HORIZON_URL_STG%" && (
ECHO Success : Map Horizon Stage URL >>"%LOGFILE%"
ECHO %HORIZON_URL_STG% >>"%LOGFILE%"
ECHO.>>"%LOGFILE%"
CALL :CHCK_MD
) || (
ECHO Failed : Map Horizon Stage URL >>"%LOGFILE%"
ECHO %HORIZON_URL_STG% >>"%LOGFILE%"
ECHO.>>"%LOGFILE%"
SET "NF1=1"& GOTO AbnormalExit
)
FOR %%E IN ( b d e f g h i j k l m n o p q r s t u v w x y z ) DO (
IF NOT EXIST %%E:\ (
SET "MD1=%%E"
NET USE !MD1!: "%HORIZON_URL_IMP%" /USER:%CREDS% >nul 2>&1 && (
ECHO Success : Map Horizon Import URL >>"%LOGFILE%"
ECHO %HORIZON_URL_IMP% >>"%LOGFILE%"
ECHO.>>"%LOGFILE%"
GOTO BREAK
) || (
ECHO Failed : Map Horizon Import URL >>"%LOGFILE%"
ECHO %HORIZON_URL_IMP% >>"%LOGFILE%"
ECHO.>>"%LOGFILE%"
SET "NF1=1"& GOTO AbnormalExit
)
)
)
)
)
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#11
Post
by ShadowThief » 08 Sep 2017 19:05
Sorry, I was posting from my phone earlier. You can't pushd web URLs, but you can pushd network folder paths. It may be different for you, but it will look something like
Code: Select all
pushd \\horizon.tttt.com\sites\rdfinance\TM1\DATA\Ascend_Headcount\Ascend_Headcount_Staging
-
SIMMS7400
- Posts: 546
- Joined: 07 Jan 2016 07:47
#12
Post
by SIMMS7400 » 09 Sep 2017 06:09
Hi Shadow -
Thanks for that clarification - I figured as much.
So I tried a few things:
Code: Select all
Runas /user:MPI\ServiceHyperion "\\horizon.tttt.com\sites\rdfinance\TM1\DATA\Ascend_Headcount\Ascend_Headcount_Staging"
But this gives me a "Trust relationship between this workstation error"
Code: Select all
PUSHD "\\horizon.tttt.com\sites\rdfinance\TM1\DATA\Ascend_Headcount\Ascend_Headcount_Staging"
This method gives me an "Access denied error". Is there a way to pass credentials to pushd?
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#13
Post
by ShadowThief » 09 Sep 2017 07:27
Oh, if you need to provide credentials pushd can't do that