Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > PC Technology Zone > Windows Operating Systems and Software » Win7 - Batch script to explore to a remote folder
Reply
Old 10-09-2009, 04:11 PM   #1 (permalink)
 
Newb Techie

Join Date: Oct 2009

Location: Denver

Posts: 12

JeffO is on a distinguished road

Default Win7 - Batch script to explore to a remote folder

Does anyone know a way to use scripting to pass credentials to a network computer or shared folder using either simple batch script or PowerShell?

I'm an IT Tech who frequently has to browse to various network folder locations. I have batch scripts that I like to use. With XP, all I had to do was the following...
Code:
cls
IF not %userdomain%==%computername% goto explore

:user
@color 1f
@set /p useris=Type Your Username: 
@color 9f
net use \\ThatNetShare\ipc$ /user:MyDomain\%useris%
@echo.
@color 07

:explore
explorer.exe \\ThatNetShare\d$
A bit fancy for a simple task, but it works regardless of situation. Of course, the meat-and-potatoes of this are simply "explorer.exe \\ThatNetShare\d$". But Windows 7 hangs on this and then fails. Part of the new security model. I think maybe I'm out-of-luck. There might no longer be a way to do this, to thwart the hackers and virus-writers.
You can type " \\ThatNetShare\d$" into an Explorer address bar, and it will prompt you for credentials, if required, and it'll work, but that's tedious. Microsoft intentionally broke the traditional way of passing credentials - and maybe they've gotten rid of it completely?

Does anyone know a way to use scripting to pass credentials to a network computer or shared folder using either simple batch script or PowerShell, that works in Windows 7?
JeffO is offline   Reply With Quote
Old 10-09-2009, 06:46 PM   #2 (permalink)
Mak213's Avatar
 

Join Date: Sep 2004

Location: C:\Windows\System32

Posts: 25,722

Mak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to allMak213 is a name known to all

Default Re: Win7 - Batch script to explore to a remote folder

From what i know it isnt possible. Your right it was done to prevent hacking and the virus writers. Cause the old way it was far to easy to get this information. You show how easy it is without having to have the proper rights you can access and obtain all information on a network.

There is no way that i know of to use any sort of script or powershell to do what you want. Maybe part of the new GPO might have something like this, but as far as executing a single script, i doubt it.
__________________
R.I.P. Danny L. Trotter
14 Nov 1945 - 4 Sept 2009
Images created by CarnageX | Decaptured...Listen! | Visit Baezware!! | You've been Mak'd! | 儿做好
I do not accept support questions via EMail, PM, IM or my Spaces page! .:|:. This is what happens when an unstoppable force meets an immovable object.
Thanks to all the guys on the staff for your support in my time of need. Hefe you are my personal Hero for your contribution.



<<<< If I help you, or you just like what I said, rep me
Mak213 is offline   Reply With Quote
Old 11-10-2009, 02:30 PM   #3 (permalink)
 
Newb Techie

Join Date: Oct 2009

Location: Denver

Posts: 12

JeffO is on a distinguished road

Default Re: Win7 - Batch script to explore to a remote folder

I got it! Very simple.
The script above breaks when trying to map to the hidden share "ipc$", which Pre-Vista machines take. Vista and later don't take this, but you can still pass credentials to an entity. Just delete \ipc$ and it works.

So, the logic of the script goes as follows...
- Check to see if the user is logging onto a corporate network domain or just the local computer (local domain, since all computers are their own mini-domain). If logging onto the local-domain, the domain name will equal the %userdomain% variable. If the user logs onto a corporate domain, then authentication will be seemless, so skip to the last command. But if the remote network-domain computer doesn't know who you are, then continue to the next section which allows you to pass credentials to the remote PC.

- The next section prompts for your username.
- The username is sent to the remote PC, which queries locally, then AD, which automatically prompts you for your password (no asterisks will appear as you type it in, but it's working).

- Then the last command tells Windows Explorer to open a window to the D: drive of the remote PC. The ipc$ hidden share is gone, but the c$, d$, etc. hidden shares still work. Windows 7 security may not allow this command to take you all the way to the remote drive, as commanded. It may instead just take you to the root machine...
\\TheRemotePC
instead of...
\\TheRemotePC\D$
But adding it to the address field of Windows Explorer manually will get you in.

So this might not be as totally fast as with XP, but at least it isn't "broken".

One reason I prefer a script instead of a shortcut is that machines and paths change - my work environment is very dynamic. I've seen shortcuts that point to non-existent places lock-up computers when clicked on. If nothing else, they slow a computer down - maybe miliseconds, maybe seconds, but add several bad shortcuts together, and especially if they're on the Desktop, and you have everything getting slowed down. A script can't have such a deleterious effect. The script might hang if you try to run it, but the computer's general performance won't suffer from it sitting there on the Desktop, or in a folder.
JeffO is offline   Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A wierd folder problem Denise_M Windows Operating Systems and Software 4 08-12-2009 11:02 AM
Help with Remote Desktop batch help KNiGHTMaRe89 Programming Discussions 2 04-29-2009 08:24 PM
Batch Script Help Please SparkMonkeyHellion Programming Discussions 6 04-17-2009 09:36 AM
Script to resize photos dropped in a folder? kizzeith Programming Discussions 10 07-12-2008 08:35 AM
Home Edition Troubles ChemicalMonkey Windows Operating Systems and Software 34 01-20-2008 09:26 PM