Creating shared drives remotely, command line

September 8, 2011 at 15:24:37
Specs: Windows XP
I am an IT Administrator with a network containing around 500 computers and I would like create a c$ (shares the C:\) for some of the computers, but not all (the last IT to work here removed them all). I would like to do this without including it in a logon script as I only would like to do this for a specific number of computers.

The script that I need would need to be able to read from a list of computers, then run the specific command on that machine.

I could go through computer management and add each of these C$'s one at a time, but that seems very time consuming and I assume that there would be an easier way via Batch, VB or C/++. Another thing to note is that the Admin$'s are also removed from every computer, so PSExec is not an option. I also have local admin rights for all of the computers on the network.

If you need any more information, don't hesitate to ask.


See More: Creating shared drives remotely, command line

Report •

September 8, 2011 at 16:22:52
(the last IT to work here removed them all).
How'd he manage that? They should be automatically recreated whenever the PC boots.

How To Ask Questions The Smart Way

Report •

September 8, 2011 at 16:46:41
All of the computers use Deepfreeze. If you are not familiar with DeepFreeze, it is a piece of software installed on a computer and it reverts any and all file changes to a stored image file after each boot of the computer.

What I plan on doing is "thawing" each of these computers on a specific date, then running the necessary script to enable the share. After that, I will have the computers revert to their "frozen" states with a new image (just created after the computer was thawed).

Any ideas on the script itself?

Report •

September 8, 2011 at 16:55:54
The shares are created programmatically; Deep Freeze shouldn't have an effect on them.

Any script would depend on how he managed to kill them.

How To Ask Questions The Smart Way

Report •

Related Solutions

September 8, 2011 at 16:58:54
It was most likely a GPO push that invoked the "NET SHARE c$ /Delete" command.

Report •

September 9, 2011 at 04:14:13
try this. u have to put it in logon script but it will run only on the computer you specify.
@echo off
::logon script to enable a network share

type Path_to_computer_list.txt | findstr /i "%computername%
if %errorlevel% == 0 Your_net_share_create_command
if %errorlevel% == 1 exit
in above lines, replace "Path_to_computer_list.txt" with the actual path of your computer list file, put it on a shared folder which sholud have read permission .
replace Your_net_share_create_command with the net share command u wanna use,depend on your requirements.

Become a Windows Geek

Report •

September 9, 2011 at 05:10:09
You can use the "rmtshare.exe" program from the Windows Resource Kit to do this. ( ) But, as others have mentioned, depending upon how the shares were removed it might not stick.

Report •

September 9, 2011 at 05:26:00
I've seen people remove the ability for the computer to hold a network share to remove the admin shares. If that's the case, using a startup script won't do anything.

I've seen people use startup scripts to remove the shares. While I no longer remember what order, if any, Windows applies its startup scripts, I'd assume it would apply the GPO supplied scripts last. If that's the case, a startup script wouldn't do anything.

Windows 2003 introduced a registry key to disable the admin shares. This would be the preferred way to kill the shares, but would require the environment to be post Win2K3 (ie Vista and Win7).

Your first step should be to figure out how he disabled the shares. Once you know, you can undo it.

If he used that registry key, thaw the system and remove the key. The removal can be scripted.

If he disabled the required services, you'll need to thaw the system, restore the network providers / services. The enabling can be scripted.

If he has a local startup script, you'll need to thaw the system and delete the script. The deletion can be scripted.

If he's pushing a script though GPO, make two computer groups. In one group, leave the offending startup script. Any PC you put in this group will have their admin shares deleted. In the other group, remove the script. Any PC you place in this group will have their admin shares restored after they reboot. This can be scripted, but it's probably faster if you just use the GUI.

EDIT: Also, I've seen people use the firewall. It doesn't kill the share so much as access to the share. Firewall settings can be scripted, but the workstation would need to be thawed.

How To Ask Questions The Smart Way

Report •

September 9, 2011 at 06:49:26
Thanks for all your help. I found a vbscript that does just what I need it to do.

Report •

Ask Question