Mr.J!M Posted May 28, 2010 Posted May 28, 2010 Helloo!!!i would like to make a BATCH or a VBS which get the HOSTNAME, supress ALL the caracters after the 7th and to add AB at the end...also i would like to connect a drive to it:net use o: \\XXXXXXXAB\folder$is it possible?
arwidmark Posted May 28, 2010 Posted May 28, 2010 It depends on if you want to use the computername or the hostname (they are normally the same) though)Here is a vbscript using the computername (run using cscript scriptname.vbs)' get computer nameSet oWshShell = CreateObject( "WScript.Shell" )Set oWshNetwork = WScript.CreateObject( "WScript.Network" )sComputerName = oWshNetwork.ComputerNamesCmd = "net use O: \\" & Left(sComputerName,7) & "AB\folder$"wscript.echo "Executing commandline: " & sCmdoWshShell.run sCmd,0,TrueHere is a vbscript using the hostname from registry (run using cscript scriptname.vbs)' get hostnameSet oWshShell = CreateObject( "WScript.Shell" )sRegValue = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname"sHostName = oWshShell.RegRead( sRegValue )sCmd = "net use O: \\" & Left(sHostName,7) & "AB\folder$"wscript.echo "Executing commandline: " & sCmdoWshShell.run sCmd,0,True
Yzöwl Posted May 28, 2010 Posted May 28, 2010 Using Windows Command ScriptExample.cmd@ECHO OFF&SETLOCAL(SET H_=)FOR /F %%# IN ('HOSTNAME') DO (SET H_=%%#)IF DEFINED H_ (NET USE O: \\%H_:~,7%AB\folder$)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now