snapin and batch script
-
@plegrand said in snapin and batch script:
@Avaryan it’s for use WsusOffline which is installed on a samba share \samba\wsus
then i need to mount the wsus share , launch a command (wsus command) dnd then umount share.Ok. That should be possible since the local users don’t need to access the mount. Should be pretty easy in PowerShell. I don’t know how to do it other ways, lol.
$Username = "Domain\User" $Password = "Password" | ConvertTo-SecureString -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password # Add share. New-PSDrive -Name "MyShare" -PSProvider FileSystem -Root \\ShareName\ -Credential $Credential # Do something... # More somethings... Remove-PSDrive -Name "MyShare"
-
@Tom-Elliott Here is what i need to do and which doesn’ works :
net use * /delete /y >> %tmp%\Update_Windows7.log 2>&1 net use z: \\samba\wsus$ "my'password" /user:samba\administrateur >> %tmp%\Update_Windows7.log 2>&1 z:\wsusoffline\client\UpdateInstaller.exe >> %tmp%\Update_Windows7.log 2>&1 net use /delete * /y >> %tmp%\Update_Windows7.log 2>&1
UpdateInstaller.exe isn’t launched
-
@Avaryan As you can see , i need to mount the share and execute a command which is inside this share…
Then i thin it’s not possible ? -
@plegrand said in snapin and batch script:
@Avaryan As you can see , i need to mount the share and execute a command which is inside this share…
Then i thin it’s not possible ?Should be possible.
$Username = "samba\administrator" $Password = "my'password" | ConvertTo-SecureString -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $Password New-PSDrive -Name "Samba" -PSProvider FileSystem -Root '\\samba\wsus$' -Credential $Credential $UpdateInstaller = Get-ChildItem -Path "Samba:\wsusoffline\client\" | Where-Object -Property Name -EQ "UpdateInstaller.exe" Start-Process -FilePath $UpdateInstaller.FullName -Wait Remove-PSDrive -Name "Samba"
Depending on how large the UpdateInstaller.exe is and how many devices you are doing at once, it might be better to have this copy it over and run locally.
-
@plegrand Does the UpdateInstaller.exe require User input?
-
@Avaryan then i use your ps script as a powershell template into snapin ?
thanks i try -
@plegrand I still doubt if that will work. If
UpdateInstaller.exe
requires user input, the script won’t run (or will be stuck running forever). -
@Tom-Elliott i’m testing the ps script, but i cant understand why it could works better than a batch script which make the same thing
-
@Avaryan it doesn’ works, the share is not mounted at all
-
@plegrand I’m asking if UpdateInstaller.exe (as you’re running it) expects user input?
-
@Tom-Elliott In fact i will not use “UpdateInstaller.exe” IRl. I will use a command line with arguments like that :
"call W:\cmd\DoUpdate.cmd /verify /updatecpp /updatetsc /instdotnet4 /autoreboot"
But this command doesnt open a window then for my test i cant see if the command is well launched or not.
But for the moment my problem is : how mount a samba share with snapin which is usable by administrator user
-
@plegrand You can’t. Not with snapins in that sense. It will be mounted by the SYSTEM user only as that’s how snapins run.
-
@plegrand said in snapin and batch script:
But for the moment my problem is : how mount a samba share with snapin which is usable by administrator user
What version of Windows would this Snapin be run on?
-
@Tom-Elliott may be with psexec tool ?
For the moment i cant make it works syntax problem but with snapin pack ? -
@Avaryan Windows 7 and Windows 10
-
@plegrand I am pretty sure, no amount of tries (with or without) snapin pack, snapin plain, psexec, powershell, batch, vbscript, or any thing else will get this working for you.
The first step would be to find out if the command is actually needing user input. Snapins cannot operate with the user environment.
-
@Tom-Elliott said in snapin and batch script:
Essentially, the reason why the “red x” happens is because System user is who mounted the point, and the permissions are not available to the user you’re actually logged in under. If you need a “global” mount of a drive, this would be more readily handled using GPO’s, not fog snapins. While I’m sure it “could” be handled via a snapin, i think such a thing is out of scope for the FOG Client.
This is correct, use Group Policy to do this. Either in a startup script or a login script. That’s how I’ve always accomplished it.
Additionally, you don’t even need to script it because Group Policy has native functionality for mapping & mounting remote volumes. -
@Tom-Elliott as i said before the command i will use will not need user input :
I will use a command line with arguments like that :
"call W:\cmd\DoUpdate.cmd /verify /updatecpp /updatetsc /instdotnet4 /autoreboot"
once share mounted in w:
I would like to update my computer once image deployed, for that i use “WsusOffline”
WsusOffline is located on a samba share, then i have to mount the samba share, in “w:” for example, and then launch this command :W:\cmd\DoUpdate.cmd /verify /updatecpp /updatetsc /instdotnet4 /autoreboot"
from the samba share
-
Based on a couple minutes of research, I don’t think you can run UpdateInstaller.exe silently. So this is likely just not going to work.
http://www.wsusoffline.net/docs/ -
@Avaryan said in snapin and batch script:
UpdateInstaller.exe
is only for testing, the command i want to launch is :
"call W:\cmd\DoUpdate.cmd /verify /updatecpp /updatetsc /instdotnet4 /autoreboot"
from the samba share